예제 #1
0
        public ActionResult FDP_Create([DataSourceRequest] DataSourceRequest request, FDPViewModel fdpViewModel, int?adminUnitID)
        {
            var result = new List <FDPViewModel>();


            if (fdpViewModel != null && ModelState.IsValid && adminUnitID.HasValue)
            {
                try
                {
                    //foreach (var viewModel in fdpViewModel)
                    //{

                    if (CheckIfDFPExists((int)adminUnitID, fdpViewModel.Name))
                    {
                        fdpViewModel.AdminUnitID = adminUnitID.Value;
                        var fdp = FDPViewModelBinder.BindFDP(fdpViewModel);
                        _fdpService.AddFDP(fdp);
                        //result.Add(fdpViewModel);
                    }
                    // }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Errors", @"Error: FDP not registered. All fields need to be filled.");
                }
            }
            return(Json(result.ToDataSourceResult(request, ModelState)));
        }
예제 #2
0
        public virtual ActionResult Create(FDP fdp)
        {
            if (ModelState.IsValid)
            {
                _FDPService.AddFDP(fdp);
                return(Json(new { success = true }));
            }

            return(PartialView(fdp));
        }
예제 #3
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));
        }
예제 #4
0
 public ActionResult FDP_Create([DataSourceRequest] DataSourceRequest request, FDPViewModel fdpViewModel, int?adminUnitID)
 {
     if (fdpViewModel != null && ModelState.IsValid && adminUnitID.HasValue)
     {
         try
         {
             fdpViewModel.AdminUnitID = adminUnitID.Value;
             var fdp = FDPViewModelBinder.BindFDP(fdpViewModel);
             _fdpService.AddFDP(fdp);
             ModelState.AddModelError("Success", @"Success: FDP Registered.");
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("Errors", @"Error: FDP not registered. All fields need to be filled.");
         }
     }
     return(Json(new[] { fdpViewModel }.ToDataSourceResult(request, ModelState)));
 }