using SepehrHotelApiSampleClient.BuiltinTypeExtensions;
using System.Collections.Generic;
using ResponseModel = Sepehr.ApiGateway.Partners.Contracts.Hotel.Availability.V4.SearchByCityAndDate.ResponseModel;

namespace SepehrHotelApiSampleClient.Availability.SearchByCityAndDate.WinForms.ViewModels
{
    public class Hotel
    {
        public int SepehrGlobalId { get; set; }

        public string Name { get; set; }

        public List<RoomType> RoomTypeList { get; set; }

        public List<Amenity> AmenityList { get; set; }

        public Hotel(ResponseModel.Hotel hotel)
        {
            SepehrGlobalId = hotel.SepehrGlobalId;
            Name = hotel.Name;
            RoomTypeList = hotel
                .RoomTypeList
                .ConvertAll(roomType => new RoomType
                {
                    SepehrGlobalId = roomType.SepehrGlobalId,
                    Name = roomType.Name,
                    AvailableRoomCount = roomType.AvailableRoomCount,
                    AdultCapacity = roomType.AdultCapacity,
                    ChildCapacity = roomType.ChildCapacity,
                    ChildAge = 5,
                    BoardTypeList = roomType
                        .BoardTypeList
                        .ConvertAll(boardType => new BoardType
                        {
                            Code = boardType.Code,
                            ExtrabedCapacity = boardType.ExtrabedCapacity,
                            RateDetailList = boardType
                                .RateDetailList
                                .ConvertAll(rateDetail => new BoardType_RateDetail
                                {
                                    Date = rateDetail.Date,
                                    Room_BoardPrice_TaxIncluded = rateDetail.Room_BoardPrice_TaxIncluded.FormattedNumber(),
                                    Room_NetPrice_TaxExcluded = rateDetail.Room_NetPrice_TaxExcluded.FormattedNumber(),
                                    Room_NetPrice_TaxIncluded = rateDetail.Room_NetPrice_TaxIncluded.FormattedNumber(),
                                    Room_NetPrice_TaxIncluded_AsDecimal = rateDetail.Room_NetPrice_TaxIncluded,
                                    Extrabed_BoardPrice_TaxIncluded = rateDetail.Extrabed_BoardPrice_TaxIncluded.FormattedNumber(),
                                    Extrabed_NetPrice_TaxExcluded = rateDetail.Extrabed_NetPrice_TaxExcluded.FormattedNumber(),
                                    Extrabed_NetPrice_TaxIncluded = rateDetail.Extrabed_NetPrice_TaxIncluded.FormattedNumber(),
                                    Extrabed_NetPrice_TaxIncluded_AsDecimal = rateDetail.Extrabed_NetPrice_TaxIncluded,
                                }),
                        }),
                    Hotel = this,
                });
            AmenityList = hotel
                .AmenityList
                .ConvertAll(amenity => new Amenity
                {
                    SepehrGlobalId = amenity.SepehrGlobalId,
                    Name = amenity.Name,
                    RateDetailList = amenity
                        .RateDetailList
                        .ConvertAll(rateDetail => new Amenity_RateDetail
                        {
                            Date = rateDetail.Date,
                            GuestAgeRangeStart = rateDetail.GuestAgeRangeStart,
                            GuestAgeRangeEnd = rateDetail.GuestAgeRangeEnd,
                            BoardPrice_TaxIncluded = rateDetail.BoardPrice_TaxIncluded.FormattedNumber(),
                            NetPrice_TaxExcluded = rateDetail.NetPrice_TaxExcluded.FormattedNumber(),
                            NetPrice_TaxIncluded = rateDetail.NetPrice_TaxIncluded.FormattedNumber(),
                            NetPrice_TaxIncluded_AsDecimal = rateDetail.NetPrice_TaxIncluded,
                        }),
                });
        }
    }
}
