public ActionResult Edit(int id) { GetRole(); var itemToEdit = repo.GetShuttleInfo(id); ShuttleManagementInfoModel model = new ShuttleManagementInfoModel() { ShuttleId = itemToEdit.shuttle_id, Time = itemToEdit.time.ToString(), Weekdays = itemToEdit.weekday, EndLocation = itemToEdit.end_location, StartLocation = itemToEdit.start_location }; return(View(model)); }
public ActionResult Create(ShuttleManagementInfoModel model) { GetRole(); if (model.StartLocation == model.EndLocation) { ViewBag.ErrorMessage = "起点和终点不能相同!"; return(View(model)); } if (model.Time == "" || model.Weekdays == "") { ViewBag.ErrorMessage = "请检查是否有空项!"; return(View(model)); } else { repo.CreateShuttle(model.Time, model.StartLocation, model.EndLocation, model.Weekdays); //TODO:发送消息逻辑 return(RedirectToAction("Index")); } }
public ActionResult Edit(ShuttleManagementInfoModel model) { GetRole(); //model.ShuttleId = int.Parse(Request.Form["id"]); if (model.StartLocation == model.EndLocation) { ViewBag.ErrorMessage = "起点和终点不能相同!"; return(View(model)); } if (model.Time == "" || model.Weekdays == "") { ViewBag.ErrorMessage = "请检查是否有空项!"; return(View(model)); } else { repo.EditShuttle(model.ShuttleId, model.Time, model.StartLocation, model.EndLocation, model.Weekdays); //TODO:发送消息逻辑 return(RedirectToAction("Index")); } }