public bool EditAdminUnit(AdminUnit adminUnit) { _unitOfWork.AdminUnitRepository.Edit(adminUnit); _unitOfWork.Save(); return true; }
public bool DeleteAdminUnit(AdminUnit adminUnit) { if (adminUnit == null) return false; _unitOfWork.AdminUnitRepository.Delete(adminUnit); _unitOfWork.Save(); return true; }
public void CanDoDeletePostBack() { //ACT var adminUnit = new AdminUnit { AdminUnitID = 1, Name = "Region", ParentID = null, AdminUnitTypeID = 2 }; dynamic result = _adminUnitController.Delete(1, adminUnit) as JsonResult; //ASSERT Assert.IsNotNull(result); Assert.AreEqual("AdminUnit/Index", result.redirect); }
public void CanDoEditPostback() { //ACT var adminUnit = new AdminUnit {AdminUnitID = 1, Name = "Region", ParentID = null, AdminUnitTypeID = 2}; var jsonResult = _adminUnitController.Edit(1, adminUnit) as JsonResult; //ASSERT Assert.IsNotNull(jsonResult); dynamic data = jsonResult.Data; Assert.AreEqual(true, data.success); }
public ActionResult Create(AdminUnitModel unit) { if (ModelState.IsValid) { try { var aunit = new AdminUnit {AdminUnitTypeID = unit.SelectedAdminUnitTypeId}; if (aunit.AdminUnitTypeID == Infrastructure.Configuration.ZoneTypeId) { aunit.ParentID = unit.SelectedRegionId; } else if (aunit.AdminUnitTypeID == Infrastructure.Configuration.WoredaTypeId) { aunit.ParentID = unit.SelectedZoneId; } aunit.Name = unit.UnitName; aunit.NameAM = unit.UnitNameAM; _adminUnitService.AddAdminUnit(aunit); return Json(new {success = true}); } catch (Exception) { return View(); } } return View("Create"); }
public ActionResult Edit(int id, AdminUnit unit) { if (ModelState.IsValid) { _adminUnitService.EditAdminUnit(unit); return Json(new {success = true}); } return PartialView("Edit", unit); }
public ActionResult Delete(int id, AdminUnit unit) { try { _adminUnitService.DeleteAdminUnit(unit); return RedirectToAction("Index"); } catch { return View("Delete"); } }