public ActionResult EditOpentime(OpentimeModel model) { if (ModelState.IsValid) { // Attempt to save the opentime try { S_Opentime opentime = OpentimeManager.GetOpentimeById(model.Id); opentime.day = (Day)Enum.Parse(typeof(Day), model.Day); opentime.openTime = model.Opentime; opentime.closeTime = model.Closetime; OpentimeManager.Update(opentime); TempData["message"] = "De openingstijd is aangepast."; return(RedirectToAction("opentimes", "Bowlinghuis", new { id = opentime.bowlingCenterId })); } catch (Exception e) { TempData["error"] = "Er is een fout opgetreden"; } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult EditOpentime(long id) { S_Opentime opentime = OpentimeManager.GetOpentimeById(id); OpentimeModel opentimeModel = new OpentimeModel(); opentimeModel.Id = opentime.id; opentimeModel.Day = opentime.day.ToString(); opentimeModel.Opentime = opentime.openTime; opentimeModel.Closetime = opentime.closeTime; SelectListItem monday = new SelectListItem(); monday.Value = "Monday"; monday.Text = "Maandag"; SelectListItem tuesday = new SelectListItem(); tuesday.Value = "Tuesday"; tuesday.Text = "Dinsdag"; SelectListItem wednesday = new SelectListItem(); wednesday.Value = "Wednesday"; wednesday.Text = "Woensdag"; SelectListItem thursday = new SelectListItem(); thursday.Value = "Thursday"; thursday.Text = "Donderdag"; SelectListItem friday = new SelectListItem(); friday.Value = "Friday"; friday.Text = "Vrijdag"; SelectListItem saterday = new SelectListItem(); saterday.Value = "Saterday"; saterday.Text = "Zaterdag"; SelectListItem sunday = new SelectListItem(); sunday.Value = "Sunday"; sunday.Text = "Zondag"; opentimeModel.Days = new Collection <SelectListItem>() { monday, tuesday, wednesday, thursday, friday, saterday, sunday }; return(View(opentimeModel)); }
public ActionResult InsertOpentime(long id) { OpentimeModel opentimeModel = new OpentimeModel(); opentimeModel.BowlingcenterId = id; SelectListItem monday = new SelectListItem(); monday.Value = "Monday"; monday.Text = "Maandag"; SelectListItem tuesday = new SelectListItem(); tuesday.Value = "Tuesday"; tuesday.Text = "Dinsdag"; SelectListItem wednesday = new SelectListItem(); wednesday.Value = "Wednesday"; wednesday.Text = "Woensdag"; SelectListItem thursday = new SelectListItem(); thursday.Value = "Thursday"; thursday.Text = "Donderdag"; SelectListItem friday = new SelectListItem(); friday.Value = "Friday"; friday.Text = "Vrijdag"; SelectListItem saterday = new SelectListItem(); saterday.Value = "Saterday"; saterday.Text = "Zaterdag"; SelectListItem sunday = new SelectListItem(); sunday.Value = "Sunday"; sunday.Text = "Zondag"; opentimeModel.Days = new Collection <SelectListItem>() { monday, tuesday, wednesday, thursday, friday, saterday, sunday }; return(View(opentimeModel)); }