tiseza_oss_live/Repositories/SectorsRepository.cs

40 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OSS.Repositories;
using OSS.Models;
namespace OSS.Repositories
{
public class SectorsRepository
{
public IEnumerable<SelectListItem> GetSectors()
{
using (var _Context = new OSSDBContext())
{
List<SelectListItem> countries = _Context.Sectors.AsNoTracking().OrderBy(t => t.SectorName)
.Select(n =>
new SelectListItem
{
Value = n.SectorName,
Text = n.SectorName
}).ToList();
var countrytip = new SelectListItem()
{
Value = null,
Text = "Please Select"
};
countries.Insert(0, countrytip);
return new SelectList(countries, "Value", "Text");
}
}
}
}