using Microsoft.Ajax.Utilities; using OSS.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace OSS.Repositories { public class RegionRepository { public IEnumerable GetRegions() { List regions = new List() { new SelectListItem { Value = null, Text = " " } }; return regions; } public IEnumerable GetRegions(long CountryID) { if (!String.IsNullOrWhiteSpace(CountryID.ToString())) { using (var context = new OSSDBContext()) { IEnumerable regions = context.Regions.AsNoTracking() .OrderBy(n => n.RegionCode) .Select(n => new SelectListItem { Value = n.RegionName, Text = n.RegionName }).ToList(); return new SelectList(regions, "Value", "Text"); } } return null; } public IEnumerable GetRegionsD(long CountryID) { if (!String.IsNullOrWhiteSpace(CountryID.ToString())) { using (var context = new OSSDBContext()) { IEnumerable regions = context.Regions.AsNoTracking() .OrderBy(n => n.RegionID) .Select(n => new SelectListItem { Value = n.RegionName.ToString(), Text = n.RegionName }).ToList(); return new SelectList(regions, "Value", "Text"); } } return null; } } }