示例#1
0
        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));
        }
示例#2
0
        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());
            }
        }