public ActionResult Create(CountryManagementModel model) { try { if (ser.IsCountryExists(model.CountryName) == true) { TempData["ErrorMessage"] = "Country already exists!"; return(View("Create", model)); } else if (ser.IsCountryCodeExists(model.CountryCode) == true) { TempData["ErrorMessage"] = "Country Code already exists!"; return(View("Create", model)); } else { ser.CreateCountry(model); } } catch { return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Edit(int Id) { CountryManagementModel model = new CountryManagementModel(); model = ser.CountryDetail(Id); model.CountryId = Id; return(View(model)); }
public ActionResult Index(int?page) { int currentPageIndex = page.HasValue ? page.Value : 1; int defaultPageSize = 30; CountryManagementModel model = new CountryManagementModel(); model.CountryManagementList = ser.ListCountry().ToPagedList(currentPageIndex, defaultPageSize); return(View(model)); }
public ActionResult Edit(int Id, CountryManagementModel model) { model.CountryId = Id; try { ser.EditCountry(model); } catch { return(View(model)); } return(RedirectToAction("Index")); }
public CountryManagementModel CountryDetail(int CountryId) { Countries result = ent.Countries.Where(x => x.CountryId == CountryId).FirstOrDefault(); CountryManagementModel model = new CountryManagementModel(); model.CountryId = result.CountryId; model.CountryCode = result.CountryCode; model.CountryName = result.CountryName; model.CountryStatus = result.CountryStatus; model.Nationality = result.Nationality; return(model); }
public void EditCountry(CountryManagementModel model) { Countries result = ent.Countries.Where(x => x.CountryId == model.CountryId).FirstOrDefault(); result.CountryId = model.CountryId; result.CountryCode = model.CountryCode; result.CountryName = model.CountryName; result.CountryStatus = model.CountryStatus; result.Nationality = model.Nationality; ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result); ent.SaveChanges(); }
public void CreateCountry(CountryManagementModel model) { Countries obj = new Countries { CountryCode = model.CountryCode, CountryName = model.CountryName, CountryStatus = "A", Nationality = model.Nationality }; ent.AddToCountries(obj); ent.SaveChanges(); }
public IEnumerable <CountryManagementModel> ListCountry() { var result = ent.Countries; List <CountryManagementModel> model = new List <CountryManagementModel>(); foreach (var item in result) { CountryManagementModel obj = new CountryManagementModel { CountryId = item.CountryId, CountryCode = item.CountryCode, CountryName = item.CountryName, CountryStatus = item.CountryStatus, Nationality = item.Nationality }; model.Add(obj); } return(model.OrderBy(x => x.CountryName)); }
public ActionResult Create() { CountryManagementModel model = new CountryManagementModel(); return(View(model)); }