public async Task <ActionResult> Index(string userId) { ApplicationUser user = null; if (userId == null && !User.IsInRole(Constants.Constants.HotelRole)) { return(Redirect("/Home/Index")); } else if (User.IsInRole(Constants.Constants.HotelRole)) { user = await profileRepository.GetUser(User.Identity.GetUserId()); } else { user = await profileRepository.GetUser(userId); } var images = new List <UserImage>(); foreach (var img in (await imageRepository.GetAllImages(user.Id))) { img.Title = "/Content/imgs/" + Path.GetFileName(img.Title); images.Add(img); } var model = new HotelProfileViewModel { CurrentUserProfile = user, Images = images, Rooms = await roomRepository.GetRoomsOfHotel(user.Id), Facilties = await facilityRepository.GetFaciltiesOfHotel(userId ?? user.Id), Reviews = await reviewRepository.GetReviewsOfHotel(userId ?? user.Id) }; return(View(model)); }
public async Task <IViewComponentResult> InvokeAsync(int id) { var model = new HotelProfileViewModel(); var hotel = _context.hotels.FirstOrDefault(p => p.HotelId == id); if (hotel != null) { model.HotelId = hotel.HotelId; model.HotelName = hotel.HotelName; model.NoOfFloors = hotel.NoOfFloors; model.NoOfRooms = hotel.NoOfRooms; model.HotelCity = hotel.HotelCity; model.Address = hotel.Address; model.HotelImage = hotel.HotelImage; model.Description = hotel.Description; } return(View(model)); }