43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
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<SelectListItem> GetWard()
|
|
{
|
|
List<SelectListItem> wards = new List<SelectListItem>()
|
|
{
|
|
new SelectListItem
|
|
{
|
|
Value = null,
|
|
Text = " "
|
|
}
|
|
};
|
|
return wards;
|
|
}
|
|
public IEnumerable<SelectListItem> GetWardOfBirth(string DistrictName)
|
|
{
|
|
|
|
using (var _Context = new OSSDBContext())
|
|
{
|
|
List<SelectListItem> 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");
|
|
}
|
|
}
|
|
}
|
|
} |