Esempio n. 1
0
 protected override AdditionalBooking DoPostPutDto(Client currentClient, AdditionalBookingDTO dto, AdditionalBooking entity, string path, object param)
 {
     if (entity == null)
     {
         entity = new AdditionalBooking();
     }
     else
     {
         if (dto.PriceTTC == null)
         {
             dto.PriceTTC = entity.PriceTTC;
         }
     }
     GetMapper.Map <AdditionalBookingDTO, AdditionalBooking>(dto, entity);
     if (path.StartsWith("AdditionalBookingDTO") && dto.Booking == null)
     {
         validationDictionnary.AddModelError("Booking", GenericError.CANNOT_BE_NULL_OR_EMPTY);
     }
     if (dto.Booking != null && dto.Booking.Id != 0)
     {
         entity.Booking = BookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Booking, currentClient, path);
     }
     if (dto.BillItemCategory != null)
     {
         entity.BillItemCategory = BillItemCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BillItemCategory, currentClient, path);
     }
     if (dto.Tax != null)
     {
         entity.Tax = TaxService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Tax, currentClient, path);
     }
     return(entity);
 }
Esempio n. 2
0
        protected override Bill DoPostPutDto(Client currentClient, BillDTO dto, Bill entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new Bill();
            }
            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.BillItems != null)
            {
                BillItemRepository.DeleteRange(entity.BillItems.Where(d => !dto.BillItems.Any(x => x.Id == d.Id)));
                dto.BillItems.ForEach(bitem =>
                {
                    if (entity.BillItems.Count != 0 && bitem.Id != 0 &&
                        entity.BillItems.Find(p => p.Id == bitem.Id) != null)
                    {
                        return;
                    }
                    BillItem toAdd = BillItemService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, bitem, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.BillItems.Add(toAdd);
                    }
                });
            }
            if (dto.PaymentMethods != null)
            {
                PaymentMethodRepository.DeleteRange(entity.PaymentMethods.Where(d => !dto.PaymentMethods.Any(x => x.Id == d.Id)));
                dto.PaymentMethods.ForEach(pm =>
                {
                    if (entity.PaymentMethods.Count != 0 && pm.Id != 0 &&
                        entity.PaymentMethods.Find(p => p.Id == pm.Id) != null)
                    {
                        return;
                    }
                    PaymentMethod toAdd = PaymentMethodService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, pm, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.PaymentMethods.Add(toAdd);
                    }
                });
            }
            if (dto.Supplier != null)
            {
                entity.Supplier = SupplierService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Supplier, currentClient, path);
            }
            return(entity);
        }
Esempio n. 3
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. 4
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. 5
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);
        }