Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public ActionResult FDP_Save([DataSourceRequest] DataSourceRequest request, FDPViewModel fdpViewModel)
        {
            if (fdpViewModel != null && ModelState.IsValid)
            {
                //var target = _fdpService.FindById(fdpViewModel.FDPID);
                var fdp = FDPViewModelBinder.BindFDP(fdpViewModel);
                _fdpService.EditFDP(fdp);
            }

            return Json(new[] { fdpViewModel }.ToDataSourceResult(request, ModelState));
        }
Ejemplo n.º 3
0
 public static FDP BindFDP(FDPViewModel fdpViewModel, FDP fdp = null)
 {
     return fdp ?? new FDP()
     {
         FDPID = fdpViewModel.FDPID,
         Name = fdpViewModel.Name,
         NameAM = fdpViewModel.NameAM,
         AdminUnitID = fdpViewModel.AdminUnitID,
         //FDPLocation = DbGeography.FromText("POINT(47.605049 48.605049)"),
         //FDPLocation = DbGeography.FromText("POINT("+fdpViewModel.longitude.ToString()+" "+fdpViewModel.latitiude+")")
         Latitude = fdpViewModel.latitude,
         Longitude = fdpViewModel.longitude
     };
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 5
0
 public ActionResult FDP_Update([DataSourceRequest] DataSourceRequest request, FDPViewModel fdpViewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var fdp = FDPViewModelBinder.BindFDP(fdpViewModel);
             _fdpService.EditFDP(fdp);
             ModelState.AddModelError("Success", @"Success: FDP Updated.");
             return RedirectToAction("Index");
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("Errors", @"Error: FDP not registered. All fields need to be filled.");
         }
     }
     return Json(new[] { fdpViewModel }.ToDataSourceResult(request, ModelState));
 }