public IActionResult AssignRoute([FromForm] AssignRouteViewModel data) { var userId = userManager.GetUserId(User); var dispatcherDb = dispatcherService.GetByUserId(userId); if (ModelState.IsValid) { var driver = driverService.GetByUserId(data.DriverId); var route = routeService.GetById(data.RouteId); dispatcherService.ConnectDriverToRoute(route, driver, dispatcherDb); } return(PartialView("_AssignRoutePartial", data)); }
public async Task <IActionResult> Index() { var user = await UserManager.GetUserAsync(User); try { var driver = DriverService.GetByUserId(user.Id); var routeEntries = DriverService.GetRouteEntries(driver.Id); var currentRoute = new CurrentRouteViewModel(); currentRoute.RouteEntries = routeEntries; currentRoute.DriverId = driver.Id; return(View(currentRoute)); } catch (Exception e) { Logger.LogDebug("Failed to retrieve driver's route entries {@Exception}", e); Logger.LogError("Failed to retrieve driver's route entries{Exception}", e.Message); return(BadRequest()); } }