public ActionResult Book(int?id) { if (id != null) { BookModel bookModel = new BookModel(); bookModel.RoomNumber = db.GetRoomList().Find(x => x.RoomId == id).RoomNumber; bookModel.RoomId = (int)id; using (RoomBookingAuthRepository dbauth = new RoomBookingAuthRepository()) { bookModel.UserId = dbauth.GetUserId(User.Identity.Name); } var bookingsOfCurrentRoom = db.GetActualBookingList().FindAll(x => x.RoomId == id); bookingsOfCurrentRoom.Sort((a, b) => a.StartOfSession.CompareTo(b.StartOfSession)); bookModel.RoomSchedule = bookingsOfCurrentRoom; return(View(bookModel)); } return(Redirect("/Home/Index")); }
public ActionResult PersonalPage(string UserName) { if (UserName != null) { PersonalPageModel personalPageModel = new PersonalPageModel(); using (RoomBookingAuthRepository dbauth = new RoomBookingAuthRepository()) { var userId = dbauth.GetUserId(UserName); var temp = db.GetBookingList().FindAll(u => u.UserId == userId); foreach (var item in temp) { personalPageModel.BookingList.Add(new Item() { RoomNumber = item.Room.RoomNumber, StartOfSession = item.StartOfSession, EndOfSession = item.EndOfSession }); } } return(View("PersonalPage", personalPageModel)); } return(View("Index")); }