public IActionResult Index(int id) { var ActiveReservationDetail = _context.roomReservations.Include(p => p.Hotelroom) .Include(p => p.Hotelroom.Hotel).Include(p => p.Hotelroom.Hotel.AppUser) .FirstOrDefault(p => p.RoomReservationId == id); if (ActiveReservationDetail == null) { return(NotFound("ReservationDetailNotFouns")); } UserReservationViewModel model = new UserReservationViewModel() { RoomName = ActiveReservationDetail.Hotelroom.RoomName, RoomNo = ActiveReservationDetail.Hotelroom.RoomNo, HotelCity = ActiveReservationDetail.Hotelroom.Hotel.HotelCity, HotelName = ActiveReservationDetail.Hotelroom.Hotel.HotelName, CheckIn = ActiveReservationDetail.ChkIndate, CheckOut = ActiveReservationDetail.ChkOutdate, NoOfNight = ActiveReservationDetail.NoOfNight, ReservationId = ActiveReservationDetail.RoomReservationId, UserId = ActiveReservationDetail.Hotelroom.Hotel.AppUser.Id, UserName = ActiveReservationDetail.UserName, RoomId = ActiveReservationDetail.Hotelroom.HotelRoomId, RoomImage = ActiveReservationDetail.Hotelroom.RoomImage }; return(View(model)); }
public IActionResult Index() { UserReservationViewModel model = null; List <UserReservationViewModel> List = new List <UserReservationViewModel>(); var OnlineUser = _userManager.GetUserAsync(HttpContext.User).Result; if (OnlineUser != null && _userManager.IsInRoleAsync(OnlineUser, "User").Result) { var Reservations = _context.roomReservations.Include(p => p.Hotelroom) .Include(p => p.Hotelroom.Hotel) .Where(p => p.Email == OnlineUser.Email) .Where(p => p.IsActive == true).ToList(); if (Reservations == null) { } foreach (var res in Reservations) { model = new UserReservationViewModel() { RoomName = res.Hotelroom.RoomName, RoomNo = res.Hotelroom.RoomNo, HotelCity = res.Hotelroom.Hotel.HotelCity, HotelName = res.Hotelroom.Hotel.HotelName, CheckIn = res.ChkIndate, CheckOut = res.ChkOutdate, NoOfNight = res.NoOfNight, ReservationId = res.RoomReservationId, UserId = OnlineUser.Id, RoomId = res.Hotelroom.HotelRoomId, HotelId = res.Hotelroom.Hotel.HotelId }; List.Add(model); } } return(View(List)); }