コード例 #1
0
ファイル: HotelRepository.cs プロジェクト: antcorpinc/Dew
        /// <summary>
        /// update hotel
        /// </summary>
        /// <param name="hotelVm"></param>
        /// <param name="LoggedInUserName"></param>
        /// <param name="resultHotel"></param>
        /// <param name="hotel"></param>
        /// <returns></returns>
        private async Task <Hotel> UpdateHotel(HotelDetailsViewModel hotelVm, string LoggedInUserName, BaseResult <List <Hotel> > resultHotel, Hotel hotel)
        {
            var hotelDb = iConnectionLibrary.GetList().Result.Result.Where(p => p.Id == hotelVm.HotelId).FirstOrDefault();

            if (hotelVm.ObjectState == ObjectState.Added)
            {
                var res = await this.CreateHotel(hotelVm, LoggedInUserName).ConfigureAwait(false);

                hotelVm.HotelId = res.Result[0].Id;

                await this.CreateAndUpdateReservationEmail(hotelVm, false).ConfigureAwait(false);

                resultHotel.Result.Add(hotel);

                await this.CreateAndUpdateReservationTelephone(hotelVm, false).ConfigureAwait(false);

                resultHotel.Result.Add(hotel);

                hotel.Id = res.Result[0].Id;
            }
            else if (hotelVm.ObjectState == ObjectState.Modified)
            {
                hotel = DbMapperMasterdata.AutomapperHotel(hotelVm, hotelDb, LoggedInUserName);
                await iConnectionLibrary.UpdateEntityByDapper(hotel as Hotel).ConfigureAwait(false);

                await this.CreateAndUpdateReservationEmail(hotelVm, true).ConfigureAwait(false);

                resultHotel.Result.Add(hotel);

                await this.CreateAndUpdateReservationTelephone(hotelVm, true).ConfigureAwait(false);

                resultHotel.Result.Add(hotel);

                resultHotel.Result.Add(hotel);
            }

            return(hotel);
        }