public NewRouteDTO CreateRoute(int driverId, int carId, int[] parcelIds) { NewRouteDTO dto; try { Route route = _routeService.CreateRoute(driverId, carId, parcelIds); foreach (RoutePoint point in route.RoutePoints) { _parcelService.AssignCourier(point.Parcel, driverId); _parcelService.ChangeParcelStatus(point.Parcel, Model.Enums.ParcelStatus.OnWayToTheCustomer); } dto = new NewRouteDTO() { Route = route, Status = Enums.NewRouteStatus.Success }; } catch (Exception ex) { dto = new NewRouteDTO() { ErrorMessage = ex.Message, Status = Enums.NewRouteStatus.Failure }; } return(dto); }
public void AssignCourier(Parcel parcelToChange, int courierId) { try { _parcelService.AssignCourier(parcelToChange, courierId); } catch (Exception e) { Console.WriteLine(e.Message); } }