当前位置: 首页>>代码示例>>C#>>正文


C# Contracts.IsNull方法代码示例

本文整理汇总了C#中Contracts.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# Contracts.IsNull方法的具体用法?C# Contracts.IsNull怎么用?C# Contracts.IsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contracts的用法示例。


在下文中一共展示了Contracts.IsNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapReservationResponse

        /// <summary>
        ///     Maps a ESS reservation response to a reservation model.
        /// </summary>
        /// <param name="reservation">Contracts.SHS2BuiltInModel.Public.Reservation</param>
        /// <returns>Reservation</returns>
        private static Reservation MapReservationResponse(Contracts.SHS2BuiltInModel.Public.Reservation reservation)
        {
            if (reservation.IsNull())
                return new Reservation();

            var guestList = reservation.GuestList.IfNotNull(
                list => list.Select(
                    guest => new Guest
                    {
                        Prefix = guest.PersonName.Prefix,
                        FirstName = guest.PersonName.GivenName,
                        LastName = guest.PersonName.Surname,
                        MiddleName = guest.PersonName.MiddleName
                    }),
                new List<Guest>());

                   var reservationModel = new Reservation
                                       {
                                           CrsConfirmationNumber = reservation.CRS_confirmationNumber,
                                           Adults = reservation.RoomStay.FirstOrDefault().IfNotNull(roomStay => roomStay.GuestCount.FirstOrDefault().IfNotNull(guestCount => guestCount.NumGuests, 0), 0),
                                           CrsCancelConfirmationNumber = reservation.CRS_cancellationNumber,
                                           CancellationPermitted = reservation.CancellationPermitted,
                                           Children = 0,
                                           BookedBy = "Not Yet Implemented",
                                           BookedOn = reservation.ResActionsActivities.ResActivityList.Where(activity => activity.ActivityType.Equals("BookDate", StringComparison.Ordinal))
                                                                 .Select(activity => activity.Date).FirstOrDefault(),
                                           BookingChannel = reservation.BookingInfo.BookingSource.PrimaryChannel.Description,
                                           Brand = "Not Yet Implemented",
                                           CancelPolicy = new CancelPolicy
                                                              {
                                                                  CancelPenaltyDate = reservation.CancelPolicy.CancelPenaltyDate,
                                                                  ChargeThreshold = reservation.CancelPolicy.ChargeThreshold,
                                                                  ChargeType = Convert.ToInt32(reservation.CancelPolicy.ChargeType),
                                                                  Description = reservation.CancelPolicy.Description,
                                                                  PenaltyAmount = reservation.CancelPolicy.CancelFeeAmount.IsNotNull()
                                                                  ? reservation.CancelPolicy.CancelFeeAmount.Value
                                                                  : (Decimal?)null
                                                              },
                                           RoomStays = reservation.RoomStay
                                                                  .Select(
                                                                      roomStay => new RoomStay
                                                                                      {
                                                                                          CrsConfirmationNumber = roomStay.CRS_confirmationNumber,
                                                                                          RateId = roomStay.Rate.Code,
                                                                                          RoomId = roomStay.Room.Code,
                                                                                          RateName = roomStay.Rate.Name,
                                                                                          RoomName = roomStay.Room.Name,
                                                                                          Nights = roomStay.NumNights,
                                                                                          StartDate = roomStay.StartDate,
                                                                                          EndDate = roomStay.EndDate
                                                                                      }).ToList(),
                                           Currency = reservation.Currency.CurrencyCode,
                                           GuaranteePolicy = new GuaranteePolicy
                                                                 {
                                                                     Description = reservation.GuaranteePolicy.Description
                                                                 },
                                           Guests = guestList,
                                           Hotel = reservation.Hotel.Name,
                                           Status = reservation.Status.ToString(),
                                           RoomRate = new RoomRate
                                                          {
                                                              AveragePrice = new AveragePrice
                                                                                 {
                                                                                     Amount = reservation.RoomPriceList.AveragePricePerNight.Price.TotalAmount,
                                                                                     AmountWithTaxesAndFees = reservation.RoomPriceList.AveragePricePerNight.Price.TotalAmountIncludingTaxesFees,
                                                                                     CurrencyCode = reservation.RoomPriceList.AveragePricePerNight.Price.CurrencyCode
                                                                                 },
                                                              PriceBreakdown = reservation.RoomPriceList.PriceBreakdownList
                                                                                          .Select(
                                                                                              product => new PriceBreakdown
                                                                                                             {
                                                                                                                 CurrencyCode = product.ProductPriceList[0].Price.CurrencyCode,
                                                                                                                 Fees = product.ProductPriceList[0].Price.Fees.Amount,
                                                                                                                 ProductRate = product.ProductPriceList[0].Product.Rate.Code,
                                                                                                                 ProductRoomName = product.ProductPriceList[0].Product.Room.Code,
                                                                                                                 Tax = product.ProductPriceList[0].Price.Tax.Amount,
                                                                                                                 Total = product.ProductPriceList[0].Price.TotalAmount,
                                                                                                                 TotalWithTaxFees = product.ProductPriceList[0].Price.TotalAmountIncludingTaxesFees
                                                                                                             }).ToList(),
                                                              TotalPrice = new TotalPrice
                                                                               {
                                                                                   Fees = new Fees
                                                                                              {
                                                                                                  Amount = reservation.RoomPriceList.TotalPrice.Price.Fees.Amount,
                                                                                                  StayFeeAmount = reservation.RoomPriceList.TotalPrice.Price.Fees.StayFeeAmount,
                                                                                                  Charges = reservation.RoomPriceList.TotalPrice.Price.Fees.BreakDown
                                                                                                                       .Select(
                                                                                                                           charge => new Charge
                                                                                                                                         {
                                                                                                                                             Amount = charge.Amount,
                                                                                                                                             Name = charge.Name,
                                                                                                                                             Type = Convert.ToInt32(charge.Type)
                                                                                                                                         }).ToList()
                                                                                              },
                                                                                   Tax = new Tax
//.........这里部分代码省略.........
开发者ID:pashanitw,项目名称:learn-matrix,代码行数:101,代码来源:ReservationServiceClient.cs


注:本文中的Contracts.IsNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。