private static District Map(EditViewModel editViewMode) { return new District { DistrictId = editViewMode.DistrictId, Name = editViewMode.DistrictName.ToUpper(), CantonId = editViewMode.CantonId, }; }
public ActionResult Create() { var editViewModel = new EditViewModel { DistrictId = 0, DistrictName = string.Empty, CantonId = 0, ProvinceId = 1, }; ViewBag.ProvincesList = _provincesManagement.GetProvinces(); ViewBag.CantonsList = _cantonsManagement.GetCantons((int)Constants.DefaultProvince); return View("Edit", editViewModel); }
public void Save(EditViewModel editViewModel) { var company = Map(editViewModel); if (editViewModel.DistrictId.Equals(0)) { AddDistrict(company); } else { EditDistrict(company); } }
public ActionResult Edit(int id) { var districtInformation = _districtsManagement.GetDistrict(id); var editViewModel = new EditViewModel { CantonId = districtInformation.CantonId, DistrictId = districtInformation.DistrictId, DistrictName = districtInformation.Name, ProvinceId = districtInformation.Canton.ProvinceId }; ViewBag.ProvincesList = _provincesManagement.GetProvinces(); ViewBag.CantonsList = _cantonsManagement.GetCantons(editViewModel.ProvinceId); return View(editViewModel); }
public ActionResult Save(EditViewModel editFormModel) { if (ModelState.IsValid) { _districtsManagement.Save(editFormModel); return RedirectToAction("Index"); } ViewBag.ProvincesList = _provincesManagement.GetProvinces(); ViewBag.CantonsList = _cantonsManagement.GetCantons(editFormModel.ProvinceId); return View("Edit", editFormModel); }