72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using OSS.Models;
|
|
|
|
namespace OSS.Repositories
|
|
{
|
|
public class Countries
|
|
{
|
|
|
|
public IEnumerable<SelectListItem> GetDistricts()
|
|
{
|
|
List<SelectListItem> districts = new List<SelectListItem>()
|
|
{
|
|
new SelectListItem
|
|
{
|
|
Value = null,
|
|
Text = " "
|
|
}
|
|
};
|
|
return districts;
|
|
}
|
|
public IEnumerable<SelectListItem> GetCountries()
|
|
{
|
|
|
|
using (var _Context = new OSSDBContext())
|
|
{
|
|
List<SelectListItem> countries = _Context.Countries.AsNoTracking().OrderBy(t => t.CountryID).Where(m=>m.CountryName!="Tanzania")
|
|
.Select(n =>
|
|
new SelectListItem
|
|
{
|
|
Value = n.CountryName,
|
|
Text = n.CountryName
|
|
}).ToList();
|
|
|
|
var countrytip = new SelectListItem()
|
|
{
|
|
Value = null,
|
|
Text = "Please Select"
|
|
};
|
|
|
|
countries.Insert(0, countrytip);
|
|
return new SelectList(countries, "Value", "Text");
|
|
}
|
|
}
|
|
public IEnumerable<SelectListItem> GetCountriesByName()
|
|
{
|
|
using (var _Context = new OSSDBContext())
|
|
{
|
|
List<SelectListItem> countries = _Context.Countries.AsNoTracking().OrderBy(t => t.CountryID)
|
|
.Select(n =>
|
|
new SelectListItem
|
|
{
|
|
Value = n.CountryID.ToString(),
|
|
Text = n.CountryName
|
|
}).ToList();
|
|
|
|
var countrytip = new SelectListItem()
|
|
{
|
|
Value = "Tanzania",
|
|
Text = "Tanzania"
|
|
};
|
|
|
|
countries.Insert(0, countrytip);
|
|
|
|
return new SelectList(countries, "Value", "Text");
|
|
}
|
|
}
|
|
}
|
|
} |