public ActionResult AddWoreda(int id) { //var donorCoverage = _hrdDonorCoverageService.FindById(id); ViewBag.RegionID = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name"); ViewBag.ZoneID = new SelectList(_adminUnitService.FindBy(m=>m.AdminUnitTypeID==3), "AdminUnitID", "Name"); ViewBag.WoredaID = new SelectList(_adminUnitService.FindBy(m => m.AdminUnitTypeID == 4), "AdminUnitID", "Name"); var addWoredaViewModel = new AddWoredaViewModel(); addWoredaViewModel.DonorCoverageID = id; return PartialView(addWoredaViewModel); }
public ActionResult AddWoreda(AddWoredaViewModel addWoredaViewModel) { if (ModelState.IsValid) { try { var donorCoverageDetail = GetCoverageDetail(addWoredaViewModel); _hrdDonorCoverageDetailService.AddWoredas(donorCoverageDetail); return RedirectToAction("Detail", new { id = addWoredaViewModel.DonorCoverageID }); } catch (Exception e) { ModelState.AddModelError("Errors",@"Unable to Add Woreda"); } } return RedirectToAction("Detail", new { id = addWoredaViewModel.DonorCoverageID }); }
private HrdDonorCoverageDetail GetCoverageDetail(AddWoredaViewModel addWoredaViewModel) { var hrdDonorCoverageDetail = new HrdDonorCoverageDetail() { HRDDonorCoverageID = addWoredaViewModel.DonorCoverageID, WoredaID = addWoredaViewModel.WoredaID }; return hrdDonorCoverageDetail; }