// POST: SelectedBooking/BookRoom public ActionResult BookRoom(string startDate, string endDate, int roomId) { DateTimeFormatInfo dk = new CultureInfo("da-DK", false).DateTimeFormat; var startDateConverted = Convert.ToDateTime(startDate, dk); var endDateConverted = Convert.ToDateTime(endDate, dk); //var user = _accountGateway.GetUserLoggedIn(); var booking = new Dll.Entities.Booking() { //Creator = user, Room = new Room { Id = roomId }, FromDate = startDateConverted, ToDate = endDateConverted, //Accepted = new List<User>(), //Invited = new List<User>() }; var bookingCreated = _bookingGateway.Create(booking); if (bookingCreated != null) { return(RedirectToAction("Bookings", "Profile")); } return(View(new BookRoomViewModel { Room = _roomGateway.Read(roomId), StartDate = startDate, EndDate = endDate, ErrorMessage = "Rummet er allerede booket i det valgte tidsrum" })); }
public ActionResult Create([Bind(Include = "Id,FromDate,ToDate")] Dll.Entities.Booking booking) { if (ModelState.IsValid) { _bookingGateway.Create(booking); return(RedirectToAction("Index")); } return(View(booking)); }
public ActionResult Edit([Bind(Include = "Id,FromDate,ToDate")] Dll.Entities.Booking booking, string startDate, string endDate) { if (ModelState.IsValid) { var bookingToUpdate = _bookingGateway.Read(booking.Id); DateTimeFormatInfo dk = new CultureInfo("da-DK", false).DateTimeFormat; bookingToUpdate.FromDate = Convert.ToDateTime(startDate, dk); bookingToUpdate.ToDate = Convert.ToDateTime(endDate, dk); _bookingGateway.Update(bookingToUpdate); return(RedirectToAction("Index")); } return(View(booking)); }