public TimeTableIndexWithRoutesViewModel GetModelWithEditRoute(int?id) { var route = this.Db.Routes.Where(x => x.Id == id).Include(x => x.Line).FirstOrDefault(); if (route == null) { return(null); } var routemodel = new EditRouteInputModel { Id = route.Id, Day = route.DayType.ToString(), RouteName = route.RouteName }; var model = new TimeTableIndexWithRoutesViewModel { EditRoute = routemodel, LineId = route.LineId, Tab = "1", Day = route.DayType.ToString(), Direction = route.Direction.ToString(), }; return(model); }
public IActionResult Edit ([Bind(Prefix = nameof(TimeTableIndexWithRoutesViewModel.EditRoute))] EditRouteInputModel model) { if (ModelState.IsValid) { return(this.RedirectToAction(nameof(TimeTableController.EditRoute), "TimeTable", new { id = model.Id })); } return(this.RedirectToAction(nameof(TimeTableController.EditRoute), "TimeTable", new { id = model.Id })); }