protected override PricePerPerson DoPostPutDto(Client currentClient, PricePerPersonDTO dto, PricePerPerson entity, string path, object param) { if (entity == null) { entity = new PricePerPerson(); } GetMapper.Map(dto, entity); if (dto.PeopleCategory != null) { entity.PeopleCategory = PeopleCategoryService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.PeopleCategory, currentClient, path); } if (dto.Period != null) { entity.Period = PeriodService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Period, currentClient, path); } if (dto.Room != null) { entity.Room = RoomService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Room, currentClient, path); } if (dto.Tax != null) { entity.Tax = TaxService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.Tax, currentClient, path); } return(entity); }
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); }