public ActionResult UpdateRoutes() { var model = new UpdateRoteViewModel() { Routes = _administrationService.GetAllRouteItems() }; return(View(model)); }
public UpdateRoteViewModel GetRouteDetalies(int id) { UpdateRoteViewModel result = new UpdateRoteViewModel(); var stopsName = _getRouteService.GetStopsNames(id); var route = _unitOfWork.RoutesRepository.GetById(id); if (stopsName.Any() && route != null) { result.RouteId = route.Id; result.StartName = stopsName.FirstOrDefault(f => f.TypeStop == TypeStopEnum.Departure)?.Name; result.StopName = stopsName.FirstOrDefault(f => f.TypeStop == TypeStopEnum.Arrival)?.Name; result.RouteNumber = route.RouteNumber; result.NumberOfSeats = route.NumberOfSeats; result.Price = route.Price; } return(result); }
public OperationResult SaveChangesRoute(UpdateRoteViewModel model) { var route = _unitOfWork.RoutesRepository.GetById(model.RouteId); if (route != null) { route.NumberOfSeats = model.NumberOfSeats; route.Price = model.Price; route.RouteNumber = model.RouteNumber; var updateResult = _unitOfWork.RoutesRepository.Update(route); if (updateResult.Successed) { return(_unitOfWork.Save()); } } return(new OperationResult { Successed = false, Message = "При изменении маршрута произошла ошибка" }); }
public ActionResult SaveChangesRoute(UpdateRoteViewModel model) { var result = _administrationService.SaveChangesRoute(model); return(Json(result)); }