// // GET: /Reservation/Select public ActionResult Select(int?id) { var model = new SelectReservationModel(); model.Rooms = this.roomsRepositoy.GetRooms(); if (id.HasValue) { model.RoomId = id.Value; } return(View("CreateReservation", model)); }
public ActionResult Select(SelectReservationModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Внесете валидни податоци!"); model.Rooms = this.roomsRepositoy.GetRooms(); return(View(model)); } bool isCreated = this.reservationRepositoy.CreateReservation(new Guid(User.Identity.GetUserId()), model.RoomId, model.FromDate, model.ToDate); if (isCreated) { // reservation is successfull - > do redirect return(RedirectToAction("MyReservations")); } ModelState.AddModelError("", "Внесете валидни податоци!"); // error, redisplay the form model.Rooms = this.roomsRepositoy.GetRooms(); return(View("CreateReservation", model)); }