Example #1
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));
        }
Example #2
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
     };
 }
Example #3
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));
 }
Example #4
0
        public void CanFDPDestory()
        {
            var kendoDataRequest = new DataSourceRequest();
            var fdpViewModel = new FDPViewModel()
            {
                FDPID = 1,
                Name = "fdpViewModel1",
                AdminUnitID = 1
            };
            var jsonResult = _fdpController.FDP_Destroy(fdpViewModel.FDPID);

            //ASSERT
            Assert.NotNull(jsonResult);
            //dynamic data = jsonResult.Data;
            //var results = data.Data as FDPViewModel;
            //Assert.NotNull(results);
            //Assert.IsInstanceOf<List<ModelStateDictionary>>(results);
        }
Example #5
0
        public void CanFDPCreateWork()
        {
            //ACT
            var kendoDataRequest = new DataSourceRequest();
            var fdpViewModel = new FDPViewModel()
                {
                    FDPID = 1,
                    Name = "fdpViewModel1",
                    AdminUnitID = 1
                };
            var jsonResult = _fdpController.FDP_Create(kendoDataRequest,fdpViewModel, 1) as JsonResult;

            //ASSERT
            Assert.NotNull(jsonResult);
            ////dynamic data = jsonResult.Data as FDPViewModel;
            //Assert.NotNull(jsonResult.Data);
            //Assert.IsInstanceOf<FDPViewModel>(jsonResult.Data);
        }
Example #6
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));
 }
Example #7
0
        public void CanFDPUpdate()
        {
            var kendoDataRequest = new DataSourceRequest();
            var fdpViewModel = new FDPViewModel()
            {
                FDPID = 1,
                Name = "fdpViewModel1",
                AdminUnitID = 1
            };
            var jsonResult = _fdpController.FDP_Save(kendoDataRequest, fdpViewModel) as JsonResult;

            //ASSERT
            Assert.NotNull(jsonResult);
            //dynamic data = jsonResult.Data;
            //var results = data.Data as FDPViewModel;
            //Assert.NotNull(results);
            //Assert.IsInstanceOf<List<FDPViewModel>>(results);
        }