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)); }
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; }
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." })); } }
public DrivesController(IDrivesService drivesService) { this.drivesService = drivesService; }
public DriveCitiesHelperService(IDrivesService drivesService, ICitiesService citiesService) { this.drivesService = drivesService; this.citiesService = citiesService; }
public IActionResult IndexPartial([FromServices] IDrivesService drivesService) { return(this.RedirectToIndexPartial(drivesService)); }
private IActionResult RedirectToIndex(IDrivesService drivesService) { IEnumerable <DriveIndexViewModel> drives = drivesService.GetAll(); return(this.View("Index", drives)); }
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 })); }
public IActionResult Details(int id, [FromServices] IDrivesService drivesService) { DriveCollectionsViewModel model = drivesService.GetDetailsModel(id, this.userId); return(this.PartialView("_DetailsPartial", model)); }
public IActionResult Delete(int id, [FromServices] IDrivesService drivesService) { DriveDeleteViewModel model = drivesService.GetDeleteModelById(id); return(this.PartialView("_DeletePartial", model)); }