예제 #1
0
        public bool EditAdminUnit(AdminUnit adminUnit)
        {
            _unitOfWork.AdminUnitRepository.Edit(adminUnit);

            _unitOfWork.Save();
            return true;
        }
예제 #2
0
        public bool DeleteAdminUnit(AdminUnit adminUnit)
        {
            if (adminUnit == null) return false;
            _unitOfWork.AdminUnitRepository.Delete(adminUnit);

            _unitOfWork.Save();
            return true;
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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");
        }
예제 #6
0
 public ActionResult Edit(int id, AdminUnit unit)
 {
     if (ModelState.IsValid)
     {
         _adminUnitService.EditAdminUnit(unit);
         return Json(new {success = true});
     }
     return PartialView("Edit", unit);
 }
예제 #7
0
 public ActionResult Delete(int id, AdminUnit unit)
 {
     try
     {
         _adminUnitService.DeleteAdminUnit(unit);
         return RedirectToAction("Index");
     }
     catch
     {
         return View("Delete");
     }
 }