コード例 #1
0
        public async Task <IActionResult> Edit(int id,
                                               DriveCreateEditViewModel model,
                                               [FromServices] IDriveHelperService driveHelperService,
                                               [FromServices] IDrivesService drivesService,
                                               [FromServices] UserManager <ApplicationUser> userManager,
                                               [FromServices] ICarsService carsService)
        {
            int userId = int.Parse(userManager.GetUserId(User));

            if (this.ModelState.IsValid)
            {
                try
                {
                    await driveHelperService.ProcessEditDriveAsync(model, id);

                    return(Json(new { success = "true", message = "Drive successfully edited." }));
                }
                catch (Exception ex)
                {
                    return(Json(new { success = "false", message = "An error has occured." }));
                }
            }

            var cars = carsService.GetSelectionListByDriver(userId);

            model.Cars = cars;
            return(this.PartialView("_EditPartial", model));
        }
コード例 #2
0
 public DriveHelperService(IDrivesService drivesService,
                           ICitiesService citiesService, ICarsService carsService,
                           IUsersService usersService, IMapper mapper)
 {
     this.drivesService = drivesService;
     this.citiesService = citiesService;
     this.carsService   = carsService;
     this.usersService  = usersService;
     this.mapper        = mapper;
 }
コード例 #3
0
 public IActionResult DeleteConfirm(int id, [FromServices] IDrivesService drivesService)
 {
     try
     {
         drivesService.Delete(id);
         return(Json(new { success = "true", message = "Drive successfully deleted." }));
     }
     catch (Exception ex)
     {
         return(Json(new { success = "false", message = "An error has occured." }));
     }
 }
コード例 #4
0
 public DrivesController(IDrivesService drivesService)
 {
     this.drivesService = drivesService;
 }
コード例 #5
0
 public DriveCitiesHelperService(IDrivesService drivesService, ICitiesService citiesService)
 {
     this.drivesService = drivesService;
     this.citiesService = citiesService;
 }
コード例 #6
0
 public IActionResult IndexPartial([FromServices] IDrivesService drivesService)
 {
     return(this.RedirectToIndexPartial(drivesService));
 }
コード例 #7
0
        private IActionResult RedirectToIndex(IDrivesService drivesService)
        {
            IEnumerable <DriveIndexViewModel> drives = drivesService.GetAll();

            return(this.View("Index", drives));
        }
コード例 #8
0
        public JsonResult Cancel(int id, [FromServices] IDrivesService drivesService)
        {
            KeyValuePair <bool, string> result = drivesService.CancelReservation(id, this.userId);

            return(Json(new { result = result.Key, message = result.Value }));
        }
コード例 #9
0
        public IActionResult Details(int id, [FromServices] IDrivesService drivesService)
        {
            DriveCollectionsViewModel model = drivesService.GetDetailsModel(id, this.userId);

            return(this.PartialView("_DetailsPartial", model));
        }
コード例 #10
0
        public IActionResult Delete(int id, [FromServices] IDrivesService drivesService)
        {
            DriveDeleteViewModel model = drivesService.GetDeleteModelById(id);

            return(this.PartialView("_DeletePartial", model));
        }