Exemple #1
0
        private string GetRoomDescription(Data.Entity.Models.Modules.Hotel.Hotel hotel)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append($"<div>{Markdown.ToHtml(hotel.Page.Description)}</div>");
            stringBuilder.Append("<div>");

            var values = hotel.Spaces.SelectMany(item => item.Translations)
                         .Where(item => item.Language.Culture == "en-US")
                         .Select(item => item.Name).ToList();

            AddSection("Spaces", values, stringBuilder);

            values = hotel.Amenities.SelectMany(item => item.Translations)
                     .Where(item => item.Language.Culture == "en-US")
                     .Select(item => item.Text).ToList();

            AddSection("Amenities", values, stringBuilder);

            values = hotel.Rules.SelectMany(item => item.Translations)
                     .Where(item => item.Language.Culture == "en-US")
                     .Select(item => item.Text).ToList();

            AddSection("Rules", values, stringBuilder);

            values = hotel.Translations.Where(item => item.Language.Culture == "en-US")
                     .Select(item => item.GettingAround).ToList();

            stringBuilder.Append("<!-- getting around -->");
            stringBuilder.Append($"<div>{string.Join("\n", values.Select(item => Markdown.ToHtml(item)))}</div>");

            stringBuilder.Append("</div>");

            return(stringBuilder.ToString());
        }
        private void AddHotelModule(Data.Entity.Models.Modules.Hotel.Hotel hotel, string culture)
        {
            if (hotel is null)
            {
                return;
            }

            var hotelModule = new HotelModuleResult
                              (
                hotel.Id,
                hotel.Translations.FirstOrDefault(t => t.Language.Culture == culture)?.GettingAround,
                hotel.Translations.FirstOrDefault(t => t.Language.Culture == culture)?.Location
                              );

            hotelModule.Amenities.AddRange(hotel.Amenities.SelectMany(a => a.Translations)
                                           .Where(t => t.Language.Culture == culture).Select(t => t.Text));

            hotelModule.Rules.AddRange(hotel.Rules.SelectMany(r => r.Translations)
                                       .Where(t => t.Language.Culture == culture).Select(t => t.Text));

            hotelModule.Spaces.AddRange(hotel.Spaces.SelectMany(s => s.Translations)
                                        .Where(t => t.Language.Culture == culture).Select(t => t.Name));

            foreach (var roomType in hotel.RoomTypes)
            {
                var roomTypeResult = new RoomTypeResult(roomType.Id, roomType.Name, roomType.Capacity);

                roomTypeResult.Beds.AddRange(
                    roomType.Beds.Select(b => new BedResult((int)b.BedType, b.BedType.ToString(), b.Count))
                    );

                hotelModule.RoomTypes.Add(roomTypeResult);
            }

            Modules.Add("hotel", hotelModule);
        }