protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Gallery.DataSource = new string[] { "blue", "orange", "brown", "red", "yellow", "green", "black", "white", "purple" }; Gallery.DataBind(); } }
private void ShowDetails(bool Available = true) { BookingTitle.Text = HttpUtility.HtmlEncode(SelectedBooking.Listing.Title); Reviews.CssClass = $"stars-{(int)SelectedBooking.Listing.AverageRating}"; Reviews.Text = SelectedBooking.Listing.RatingCount == 0 ? "No reviews" : SelectedBooking.Listing.RatingCount == 1 ? "One review" : $"{SelectedBooking.Listing.RatingCount} reviews"; Reviews.NavigateUrl = $"/account/listing/reviews?lid={SelectedBooking.ListingId}"; Gallery.DataSource = SelectedBooking.Listing.Photos; Gallery.DataBind(); Description.Text = HttpUtility.HtmlEncode(SelectedBooking.Listing.Description); Brand.Text = HttpUtility.HtmlEncode(SelectedBooking.Listing.Brand); HorsePower.Text = HttpUtility.HtmlEncode(SelectedBooking.Listing.HorsePower); Year.Text = HttpUtility.HtmlEncode(SelectedBooking.Listing.Year); if (SelectedBooking.StartDate.Date == SelectedBooking.EndDate.Date) { Dates.Text = SelectedBooking.StartDate.ToString("d MMMM yyyy"); } else if (SelectedBooking.StartDate.ToString("MM/yy") == SelectedBooking.EndDate.ToString("MM/yy")) { Dates.Text = SelectedBooking.StartDate.Day + " - " + SelectedBooking.EndDate.ToString("d MMMM yyyy"); } else { Dates.Text = SelectedBooking.StartDate.ToString("d MMMM yyyy") + " - " + SelectedBooking.EndDate.ToString("d MMMM yyyy"); } var days = (SelectedBooking.EndDate - SelectedBooking.StartDate).TotalDays + 1; Days.Text = days == 1 ? "1 day" : $"{days} days"; AvailabilityDays.Attributes.Add("ng-init", $"calendar.days={days}"); ListingId.Attributes.Add("ng-init", $"calendar.listingId={SelectedBooking.ListingId}"); StartDate.Attributes.Add("ng-init", $"calendar.startDate=calendar.date('{SelectedBooking.StartDate.ToString("yyy-MM-dd")}')"); Availability.Visible = SelectedBooking.Id == 0; // !Available; Unavaiable.Visible = !Available; TransportDistance.Text = SelectedBooking.TransportDistance.ToString("N2") + " km"; TransportCost.Text = "$" + SelectedBooking.TransportCost.ToString("N2"); HireSize.Text = SelectedBooking.Quantity + " " + SelectedBooking.Service.QuantityUnit + "s"; HireCost.Text = "$" + SelectedBooking.HireCost.ToString("N2"); if (SelectedBooking.Listing.CategoryId == Core.Entities.Category.LorriesId) { FuelSize.Text = SelectedBooking.TransportDistance.ToString("N2") + "km"; } else { FuelSize.Text = SelectedBooking.Quantity + " " + SelectedBooking.Service.QuantityUnit + "s"; } FuelCost.Text = "$" + SelectedBooking.FuelCost.ToString("N2"); CommissionRow.Visible = SelectedBooking.Listing.UserId == Master.CurrentUser.Id; Commission.Text = "$" + SelectedBooking.AgriShareCommission.ToString("N2"); Total.Text = "$" + SelectedBooking.Price.ToString("N2"); /******************************/ var isSeeker = SelectedBooking.UserId == Master.CurrentUser.Id; var isOfferer = SelectedBooking.Listing.UserId == Master.CurrentUser.Id; RequestPanel.Visible = isSeeker && SelectedBooking.Id == 0 && Available; AwaitingConfirmPanel.Visible = isSeeker && SelectedBooking.StatusId == Core.Entities.BookingStatus.Pending; PendingPanel.Visible = isOfferer && SelectedBooking.StatusId == Core.Entities.BookingStatus.Pending; DeclinedPanel.Visible = SelectedBooking.StatusId == Core.Entities.BookingStatus.Declined; AwaitingPaymentPanel.Visible = isOfferer && SelectedBooking.StatusId == Core.Entities.BookingStatus.Approved; PaidPanel.Visible = isOfferer && SelectedBooking.StatusId == Core.Entities.BookingStatus.InProgress; InProgressPanel.Visible = isSeeker && SelectedBooking.StatusId == Core.Entities.BookingStatus.InProgress; IncompletePanel.Visible = isOfferer && SelectedBooking.StatusId == Core.Entities.BookingStatus.Incomplete; CompletePanel.Visible = SelectedBooking.StatusId == Core.Entities.BookingStatus.Complete; CancelledPanel.Visible = SelectedBooking.StatusId == Core.Entities.BookingStatus.Cancelled; if (isSeeker && SelectedBooking.StatusId == Core.Entities.BookingStatus.Approved) { var bookingUsers = Core.Entities.BookingUser.List(BookingId: SelectedBooking.Id); if (bookingUsers == null || bookingUsers.Select(o => o.Ratio).DefaultIfEmpty(0).Sum() < 1) { PaymentPanel.Visible = isSeeker && SelectedBooking.StatusId == Core.Entities.BookingStatus.Approved && SelectedBooking.ForId != Core.Entities.BookingFor.Group; GroupPaymentPanel.Visible = isSeeker && SelectedBooking.StatusId == Core.Entities.BookingStatus.Approved && SelectedBooking.ForId == Core.Entities.BookingFor.Group; if (bookingUsers?.Count > 0) { var arr = bookingUsers.Select(e => new BookingUserModel { Id = e.Id, Name = e.Name, Quantity = e.Ratio * SelectedBooking.Quantity, Telephone = e.Telephone }); BookingUsers.Attributes.Add("ng-init", "group.users=" + JsonConvert.SerializeObject(arr)); } else { BookingUsers.Attributes.Add("ng-init", "group.users=[{},{}]"); } } else { PaymentProgressPanel.Visible = true; PaymentProgressPanel.Attributes.Add("ag-booking-id", SelectedBooking.Id.ToString()); } } if (PaymentPanel.Visible && SelectedBooking.ForId == Core.Entities.BookingFor.Me) { PayerMobileNumber.Text = Master.CurrentUser.Title; PayerMobileNumber.Text = Master.CurrentUser.Telephone; } if (CompletePanel.Visible) { var rating = Core.Entities.Rating.Find(BookingId: SelectedBooking.Id); if (rating.Id > 0) { Review.Visible = true; ReviewStars.Attributes.Add("class", $"stars-{(int)rating.Stars}"); ReviewUser.Text = HttpUtility.HtmlEncode(rating.User.FirstName); ReviewComments.Text = HttpUtility.HtmlEncode(rating.Comments); ReviewDate.Text = rating.DateCreated.ToString("d MMMM yyyy"); } } }