protected override DinnerBooking DoPostPutDto(Client currentClient, DinnerBookingDTO dto, DinnerBooking entity, string path, object param) { if (entity == null) { entity = new DinnerBooking(); } 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.MealBookings != null) { MealRepository.DeleteRange(entity.MealBookings.Where(d => !dto.MealBookings.Any(x => x.Id == d.Id))); dto.MealBookings.ForEach(mealBooking => { if (entity.MealBookings.Count != 0 && mealBooking.Id != 0 && entity.MealBookings.Find(p => p.Id == mealBooking.Id) != null) { return; } MealBooking toAdd = MealBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, mealBooking, currentClient, path); if (toAdd != null) { entity.MealBookings.Add(toAdd); } }); } return(entity); }