public ActionResult Region(ViewModels.StateViewModel model) { bool isSuccess = false; if (model.Region.CityId < 1) { ViewBag.StateIsSuccess = false; ViewBag.CityIsSuccess = false; ViewBag.RegionIsSuccess = false; ModelState.AddModelError("Region.CityId", "City Feild is Required."); return(View("State", GetAllMasterDetails())); } var data = (regionRepo.FilteredGet().Where(x => x.Name.ToUpper() == model.Region.Region.ToUpper())).FirstOrDefault(); if (data == null) { var newRegion = new Data.Models.Regions { Name = model.Region.Region, CityId = model.Region.CityId }; regionRepo.Insert(newRegion); isSuccess = true; } else { ModelState.AddModelError("Region.Name", "Region With Name Already Exists."); } ViewBag.StateIsSuccess = false; ViewBag.CityIsSuccess = false; ViewBag.RegionIsSuccess = isSuccess; return(View("State", GetAllMasterDetails())); }
public ActionResult State(ViewModels.StateViewModel model) { bool isSuccess = false; var data = (stateRepo.FilteredGet().Where(x => x.Name.ToUpper() == model.States.Name.ToUpper())).FirstOrDefault(); if (data == null) { var newState = new Data.Models.State { Name = model.States.Name }; stateRepo.Insert(newState); isSuccess = true; } else { ModelState.AddModelError("States.Name", "State With Name Already Exists."); } ViewBag.StateIsSuccess = isSuccess; ViewBag.CityIsSuccess = false; ViewBag.RegionIsSuccess = false; return(View(GetAllMasterDetails())); }