using OSS.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace OSS.Repositories { public class WardRepository { public IEnumerable GetWard() { List wards = new List() { new SelectListItem { Value = null, Text = " " } }; return wards; } public IEnumerable GetWardOfBirth(string DistrictName) { using (var _Context = new OSSDBContext()) { List listofWards = _Context.Wards.AsNoTracking().OrderBy(t => t.WardID) .Where(t=>t.DistrictName==DistrictName) .Select(n => new SelectListItem { Value = n.WardName, Text = n.WardName }).ToList(); return new SelectList(listofWards, "Value", "Text"); } } } }