Esempio n. 1
0
 public virtual ActionResult Create(AdminUnitModel fdps)
 {
     var fdp = new FDP
         {
             Name = fdps.UnitName,
             NameAM = fdps.UnitNameAM,
             AdminUnitID = fdps.SelectedWoredaId
         };
     if (ModelState.IsValid)
     {
         _FDPService.AddFDP(fdp);
         return Json(new { success = true });
     }
     return PartialView(fdps);
 }
Esempio n. 2
0
 //
 // GET: /FDP/Create
 public virtual ActionResult Create(int? woredaId)
 {
     var adminUnit = _adminUnitService.Get(t=>t.AdminUnitID == woredaId, null, "AdminUnit2,AdminUnit2.AdminUnit2").FirstOrDefault();
     var adminUnitModel = new AdminUnitModel();
     if (adminUnit != null)
     {
         if (adminUnit.AdminUnit2.ParentID != null)
             adminUnitModel = new AdminUnitModel
                 {
                     SelectedWoredaId = adminUnit.AdminUnitID,
                     SelectedZoneId = adminUnit.AdminUnit2.AdminUnitID,
                     SelectedRegionId = (int) adminUnit.AdminUnit2.ParentID,
                     SelectedWoredaName = adminUnit.Name,
                     SelectedZoneName = adminUnit.AdminUnit2.Name,
                     SelectedRegionName = adminUnit.AdminUnit2.AdminUnit2.Name
                 };
     }
     return PartialView(adminUnitModel);
 }
Esempio n. 3
0
 public ActionResult Create(int typeid)
 {
     var model = new AdminUnitModel();
     switch (typeid)
     {
         case 2:
             model.SelectedAdminUnitTypeId = Infrastructure.Configuration.RegionTypeId;
             return PartialView("CreateRegion", model);
         case 3:
             model.SelectedAdminUnitTypeId = Infrastructure.Configuration.ZoneTypeId;
             return PartialView("CreateZone", model);
         case 4:
             model.SelectedAdminUnitTypeId = Infrastructure.Configuration.WoredaTypeId;
             return View("CreateWoreda", model);
         default:
             model.SelectedAdminUnitTypeId = Infrastructure.Configuration.RegionTypeId;
             return PartialView("CreateRegion", model);
     }
 }
Esempio n. 4
0
        public void CanViewCreate()
        {
            //ACT
            var adminUnitModel = new AdminUnitModel { UnitName = "W. Arsi" };
            var jsonResult = _adminUnitController.Create(adminUnitModel) as JsonResult;

            //ASSERT
            Assert.IsNotNull(jsonResult);
            dynamic data = jsonResult.Data;
            Assert.AreEqual(true, data.success);
        }
Esempio n. 5
0
        private void PrepareFDPForEdit(int? fdpid)
        {
            var unitModel = new AdminUnitModel();
            var fdp = fdpid != null ? _fdpService.FindById(fdpid.Value) : null;
            if (fdp != null)
            {
                unitModel.SelectedWoredaId = fdp.AdminUnitID;
                if (fdp.AdminUnit.ParentID != null) unitModel.SelectedZoneId = fdp.AdminUnit.ParentID.Value;

                unitModel.SelectedRegionId = _adminUnitService.GetRegionByZoneId(unitModel.SelectedZoneId);
                ViewBag.SelectedRegionId = new SelectList(_adminUnitService.GetRegions().Select(p => new { Id = p.AdminUnitID, p.Name }).OrderBy(o => o.Name), "Id", "Name", unitModel.SelectedRegionId);
                ViewBag.SelectedZoneId = new SelectList(GetChildren(unitModel.SelectedRegionId).OrderBy(o => o.Name), "Id", "Name", unitModel.SelectedZoneId);
                ViewBag.SelectedWoredaId = new SelectList(GetChildren(unitModel.SelectedZoneId).OrderBy(o => o.Name), "Id", "Name", unitModel.SelectedWoredaId);
                ViewBag.FDPID = new SelectList(GetFdps(unitModel.SelectedWoredaId).OrderBy(o => o.Name), "Id", "Name", fdp.FDPID);
            }
            else
            {
                ViewBag.SelectedRegionId = new SelectList(unitModel.Regions, "Id", "Name");
                ViewBag.SelectedWoredaId = new SelectList(Enumerable.Empty<SelectListItem>(), "Id", "Name");
                ViewBag.FDPID = new SelectList(Enumerable.Empty<SelectListItem>(), "Id", "Name");
                ViewBag.SelectedZoneId = new SelectList(Enumerable.Empty<SelectListItem>(), "Id", "Name");
            }
        }
Esempio n. 6
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");
        }
Esempio n. 7
0
 public ActionResult CreateZone(int? regionId)
 {
     var model = new AdminUnitModel();
     if (regionId.HasValue)
     {
         var region = _adminUnitService.FindById(regionId.Value);
         model.SelectedRegionId = region.AdminUnitID;
         model.SelectedRegionName = region.Name;
     }
     model.SelectedAdminUnitTypeId = Infrastructure.Configuration.ZoneTypeId;
     return PartialView("CreateZone", model);
 }
Esempio n. 8
0
        public ActionResult CreateWoreda(int? zoneId)
        {
            var model = new AdminUnitModel { SelectedAdminUnitTypeId = Infrastructure.Configuration.WoredaTypeId };

            if (zoneId.HasValue)
            {
                var zone = _adminUnitService.FindById(zoneId.Value);
                model.SelectedZoneName = zone.Name;
                model.SelectedZoneId = zone.AdminUnitID;
                model.SelectedRegionId = zone.AdminUnit2.AdminUnitID;
                model.SelectedRegionName = zone.AdminUnit2.Name;
            }
            return PartialView("CreateWoreda", model);
        }
Esempio n. 9
0
 public ActionResult CreateRegion()
 {
     var model = new AdminUnitModel { SelectedAdminUnitTypeId = Infrastructure.Configuration.RegionTypeId };
     return PartialView("CreateRegion", model);
 }