Exemple #1
0
        //public CheckoutRoomInformationModel(ReservationItem reservationItem)
        //{
        //    //Id = reservationItem.Id;
        //    NameOfPrimaryGuest = reservationItem.NameOfPrimaryGuest;
        //    ItemType = reservationItem.Description;
        //    Adults = reservationItem.TotalNumberOfGuests;
        //}
        public CheckoutRoomInformationModel(ReservationItem reservationItem, SearchResultRoom roomtype, IEnumerable<Addon> addons)
        {
            Id = Guid.NewGuid();

            Addons = addons.Select(x =>
                new CheckoutAddonItemModel(
                    x.Id,
                    x.Name.GetText(LanguageTypeEnum.English),
                    x.Description.GetText(LanguageTypeEnum.English),
                    x.Price,
                    x.PostingRhythm,
                    x.CalculationRule)
            ).ToList();

            NameOfPrimaryGuest = reservationItem.NameOfPrimaryGuest;
            ItemType = reservationItem.Description;
            Adults = reservationItem.TotalNumberOfGuests;

            Adults = (roomtype.MaxCapacity == 1) ? 1 : 0;

            TotalPrice = roomtype.TotalPrice;

            Guests = Enumerable.Range(1, roomtype.MaxCapacity).Select(x => new SelectListItem { Selected = (x == roomtype.MaxCapacity && x == 1), Text = x.ToString(), Value = x.ToString() }).ToList();
            if (roomtype.MaxCapacity > 1)
            {
                Guests.Insert(0, new SelectListItem { Selected = false, Text = "0", Value = string.Empty });
            }
        }
Exemple #2
0
        internal static SearchResultRoom Create(RoomType roomType, IEnumerable<ReservationItem> reservationItems, IEnumerable<RoomTypeInventory> inventories, IEnumerable<RatePrice> prices, DateTime arrival, DateTime depature)
        {
            var minimumQuantity = int.MaxValue;
            var hasAvailableQuantity = false;
            var inventoryPricePerDays = new List<SearchResultRoomPrice>();

            var reservationPrices = reservationItems.SelectMany(x => x.PricePerDate);
            var days = (depature - arrival).Days;

            for (var i = 0; i < days; i++)
            {
                var date = arrival.AddDays(i);

                var availableQuantity = FindAvailableQuantity(roomType.Quantity, date, inventories, reservationPrices);
                var price = FindPrice(roomType.RackRate, date, inventories, prices);

                var inventoryPricePerDay = SearchResultRoomPrice.Create(date, availableQuantity, price);
                inventoryPricePerDays.Add(inventoryPricePerDay);

                minimumQuantity = Math.Min(availableQuantity, minimumQuantity);
                hasAvailableQuantity = availableQuantity > 0;

                if(hasAvailableQuantity == false)
                {
                    // The room is not available for one of the selected days
                    break;
                }
            }

            var resultRoom = new SearchResultRoom
                                 {
                                     RoomTypeId = roomType.Id,
                                     Name = roomType.Name.GetText(LanguageTypeEnum.English),
                                     Description = roomType.Description.GetText(LanguageTypeEnum.English),
                                     IsAvailable = hasAvailableQuantity,
                                     LowestPricePerDay = inventoryPricePerDays.Min(x => x.Price),
                                     TotalPrice = inventoryPricePerDays.Sum(x => x.Price),
                                     AvailableQuantity = minimumQuantity,
                                     MaxCapacity = roomType.Capacity,
                                     Prices = inventoryPricePerDays,
                                     Thumbnails = roomType.Assets.Select(x => x.GenerateUrl(250, 155) + x.GenerateCroppingQuery())
                                 };

            return resultRoom;
        }