68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
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<SelectListItem> GetRegions()
|
|
{
|
|
List<SelectListItem> regions = new List<SelectListItem>()
|
|
{
|
|
new SelectListItem
|
|
{
|
|
Value = null,
|
|
Text = " "
|
|
}
|
|
};
|
|
return regions;
|
|
}
|
|
|
|
public IEnumerable<SelectListItem> GetRegions(long CountryID)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(CountryID.ToString()))
|
|
{
|
|
using (var context = new OSSDBContext())
|
|
{
|
|
IEnumerable<SelectListItem> 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<SelectListItem> GetRegionsD(long CountryID)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(CountryID.ToString()))
|
|
{
|
|
using (var context = new OSSDBContext())
|
|
{
|
|
IEnumerable<SelectListItem> 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;
|
|
}
|
|
}
|
|
} |