public Surveys GetSurveysByCode(string code) { var surveys = GetAll().FirstOrDefault(x => x.Code == code); if (surveys != null) { var booking = BookingList.FirstOrDefault(b => b.BookingId == surveys.BookingId); if (booking != null) { var product = ProductList.FirstOrDefault(p => p.ProductId == booking.ProductId); surveys.RedeemedDate = booking.RedeemedDate; surveys.HotelPrice = booking.HotelPrice; if (product != null) { var hotel = HotelList.FirstOrDefault(h => h.HotelId == product.HotelId); string imageUrl = Constant.ImageDefault; var image = ProductImageList.FirstOrDefault(x => x.ProductId == product.ProductId && x.IsCover && x.IsActive); if (image != null) { imageUrl = image.Url; } surveys.ImageUrl = imageUrl; if (hotel != null) { surveys.HotelInfo = string.Format("{0} at {1}<br/> {2}, {3}", product.ProductName, hotel.HotelName, hotel.Neighborhood, hotel.City); } } } } return(surveys); }
private void SetImagePathForProducts(ref List <Products> entities) { entities.ForEach(item => { string imageUrl = Constant.ImageDefault; var image = ProductImageList.FirstOrDefault(x => x.ProductId == item.ProductId && x.IsCover && x.IsActive); if (image != null) { imageUrl = image.Url; } try { item.AdminImageUrl = imageUrl; item.ImageUrl = string.Format("{0}", new Uri(new Uri(AppConfiguration.CdnImageUrlDefault), imageUrl).AbsoluteUri); } catch (Exception) { item.ImageUrl = imageUrl; } }); }