Esempio n. 1
0
 protected override BookingStepBooking DoPostPutDto(Client currentClient, BookingStepBookingDTO dto, BookingStepBooking entity, string path, object param)
 {
     if (entity == null)
     {
         entity = new BookingStepBooking();
     }
     GetMapper.Map <BookingStepBookingDTO, BookingStepBooking>(dto, entity);
     if (dto.Booking != null && dto.Booking.Id != 0)
     {
         entity.Booking = BookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Booking, currentClient, path);
     }
     if (dto.BookingStepConfig != null)
     {
         entity.BookingStepConfig = BookingStepConfigService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BookingStepConfig, currentClient, path);
     }
     if (entity.CurrentStep == null && dto.CurrentStep != null)
     {
         entity.CurrentStep = BookingStepService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.CurrentStep, currentClient, path);
     }
     return(entity);
 }
Esempio n. 2
0
 protected override ProductBooking DoPostPutDto(Client currentClient, ProductBookingDTO dto, ProductBooking entity, string path, object param)
 {
     if (entity == null)
     {
         entity = new ProductBooking();
     }
     else
     {
         if (dto.PriceHT == null)
         {
             dto.PriceHT = entity.PriceHT;
         }
         if (dto.PriceTTC == null)
         {
             dto.PriceTTC = entity.PriceTTC;
         }
     }
     GetMapper.Map(dto, entity);
     if (dto.Booking != null && dto.Booking.Id != 0)
     {
         entity.Booking = BookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Booking, currentClient, path);
     }
     if (dto.Product != null)
     {
         entity.Product = ProductService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Product, currentClient, path);
     }
     if (entity.Product != null && entity.Product.Duration == null)
     {
         if (entity.Product.Stock != null)
         {
             entity.Product.Stock -= entity.Quantity;
             SetThresholdFlag(entity);
         }
     }
     return(entity);
 }
Esempio n. 3
0
        protected override RoomBooking DoPostPutDto(Client currentClient, RoomBookingDTO dto, RoomBooking entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new RoomBooking();
            }
            else
            {
                if (dto.PriceHT == null)
                {
                    dto.PriceHT = entity.PriceHT;
                }
                if (dto.PriceTTC == null)
                {
                    dto.PriceTTC = entity.PriceTTC;
                }
            }
            GetMapper.Map(dto, entity);
            if (dto.Booking != null && dto.Booking.Id != 0)
            {
                entity.Booking = BookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Booking, currentClient, path);
            }
            if (dto.Room != null)
            {
                entity.Room = RoomService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Room, currentClient, path);
            }
            if (dto.PeopleBookings != null)
            {
                PeopleBookingRepository.DeleteRange(entity.PeopleBookings.Where(d => !dto.PeopleBookings.Any(x => x.Id == d.Id)));
                dto.PeopleBookings.ForEach(peopleBooking =>
                {
                    if (entity.PeopleBookings.Count != 0 && peopleBooking.Id != 0 &&
                        entity.PeopleBookings.Find(p => p.Id == peopleBooking.Id) != null)
                    {
                        return;
                    }
                    PeopleBooking toAdd = PeopleBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, peopleBooking, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.PeopleBookings.Add(toAdd);
                    }
                });
            }
            if (dto.SupplementRoomBookings != null)
            {
                SupplementRoomBookingRepository.DeleteRange(entity.SupplementRoomBookings.Where(d => !dto.SupplementRoomBookings.Any(x => x.Id == d.Id)));
                dto.SupplementRoomBookings.ForEach(supplementRoomBooking =>
                {
                    if (entity.SupplementRoomBookings.Count != 0 && supplementRoomBooking.Id != 0 &&
                        entity.SupplementRoomBookings.Find(p => p.Id == supplementRoomBooking.Id) != null)
                    {
                        return;
                    }
                    SupplementRoomBooking toAdd = SupplementRoomBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, supplementRoomBooking, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.SupplementRoomBookings.Add(toAdd);
                    }
                });
            }
            return(entity);
        }