Exemplo n.º 1
0
        /// <summary>
        /// update payment method relation
        /// </summary>
        /// <param name="hotelVm"></param>
        /// <param name="resultHotel"></param>
        /// <param name="hotel"></param>
        /// <returns></returns>
        private async Task UpdatePaymentMethodRelation(HotelDetailsViewModel hotelVm, BaseResult <List <Hotel> > resultHotel, Hotel hotel)
        {
            var paymentDbList = iHotelPaymentMethodRelation.GetList().Result.Result;

            if (hotelVm.HotelPaymentMethodRelation.ObjectState == ObjectState.Added)
            {
                hotelVm.HotelPaymentMethodRelation.HotelId = hotel.Id;
                await this.CreateHotelPaymentMethodRelation(hotelVm.HotelPaymentMethodRelation).ConfigureAwait(false);

                resultHotel.Result.Add(hotel);
            }
            else if (hotelVm.HotelPaymentMethodRelation.ObjectState == ObjectState.Modified)
            {
                var paymentDb = paymentDbList.Where(p => p.Id == hotelVm.HotelPaymentMethodRelation.HotelPaymentMethodRelationId).FirstOrDefault();
                paymentDb.HotelId = hotel.Id;
                HotelPaymentMethodRelation payment = DbMapperMasterdata.AutomapperPaymentMethodRelation(hotelVm.HotelPaymentMethodRelation, paymentDb);
                await iHotelPaymentMethodRelation.UpdateEntityByDapper(payment).ConfigureAwait(false);

                resultHotel.Result.Add(hotel);
            }
        }