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); }
public SearchDataResponse SearchData() { var result = new SearchDataResponse { ListBookings = DayaxeDbContext.Bookings.OrderByDescending(x => x.BookingId).ToList(), ListCustomerInfos = CustomerInfoList.Where(c => !c.IsDelete).ToList() }; result.ListBookings.ForEach(booking => { var product = ProductList.FirstOrDefault(p => p.ProductId == booking.ProductId); var hotel = HotelList.FirstOrDefault(h => h.HotelId == (product != null ? product.HotelId : 0)); booking.BookingsTypeString = product != null ? GetProductType(product.ProductType) : string.Empty; booking.TimeZoneId = hotel != null ? hotel.TimeZoneId : string.Empty; }); result.ListCustomerInfos.ForEach(customer => { var discount = GetSubscriptionDiscount(customer.CustomerId); if (discount != null) { customer.SubscriptionCode = discount.Code; } }); return(result); }