protected override PeopleField DoPostPutDto(Client currentClient, PeopleFieldDTO dto, PeopleField entity, string path, object param) { if (entity == null) { entity = new PeopleField(); } GetMapper.Map(dto, entity); if (dto.FieldGroup != null) { entity.FieldGroup = FieldGroupService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.FieldGroup, currentClient, path); } if (dto.People != null) { entity.People = PeopleService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.People, currentClient, path); } return(entity); }
//TODO BookingDocument protected override Booking DoPostPutDto(Client currentClient, BookingDTO dto, Booking entity, string path, object param) { if (entity == null) { entity = new Booking(); } GetMapper.Map <BookingDTO, Booking>(dto, entity); HomeConfig hc = HomeConfigRepository.GetHomeConfigById(entity.HomeId, currentClient.Id); if (hc != null) { if (hc.DefaultHourCheckIn != null) { entity.DateArrival = ((DateTime)entity.DateArrival).Date.Add(hc.DefaultHourCheckInToTimeSpan); } if (hc.DefaultHourCheckOut != null) { entity.DateDeparture = ((DateTime)entity.DateDeparture).Date.Add(hc.DefaultHourCheckOutToTimeSpan); } } if (dto.People != null) { entity.People = PeopleService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.People, currentClient, path); } if (dto.AdditionalBookings != null) { AdditionalBookingRepository.DeleteRange(entity.AdditionalBookings.Where(d => !dto.AdditionalBookings.Any(x => x.Id == d.Id))); dto.AdditionalBookings.ForEach(additionalBooking => { if (entity.AdditionalBookings.Count != 0 && additionalBooking.Id != 0 && entity.AdditionalBookings.Find(p => p.Id == additionalBooking.Id) != null) { return; } AdditionalBooking toAdd = AdditionalBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, additionalBooking, currentClient, path); if (toAdd != null) { entity.AdditionalBookings.Add(toAdd); } }); } if (dto.BookingStepBooking != null) { entity.BookingStepBooking = BookingStepBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BookingStepBooking, currentClient, path); } if (dto.Deposits != null) { DepositRepository.DeleteRange(entity.Deposits.Where(d => !dto.Deposits.Any(x => x.Id == d.Id))); dto.Deposits.ForEach(deposit => { if (entity.Deposits.Count != 0 && deposit.Id != 0 && entity.Deposits.Find(p => p.Id == deposit.Id) != null) { return; } Deposit toAdd = DepositService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, deposit, currentClient, path); if (toAdd != null) { entity.Deposits.Add(toAdd); } }); } if (dto.DinnerBookings != null) { DinnerBookingRepository.DeleteRange(entity.DinnerBookings.Where(d => !dto.DinnerBookings.Any(x => x.Id == d.Id))); dto.DinnerBookings.ForEach(dinnerBooking => { if (entity.DinnerBookings.Count != 0 && dinnerBooking.Id != 0 && entity.DinnerBookings.Find(p => p.Id == dinnerBooking.Id) != null) { return; } DinnerBooking toAdd = DinnerBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dinnerBooking, currentClient, path); if (toAdd != null) { entity.DinnerBookings.Add(toAdd); } }); } if (dto.ProductBookings != null) { ProductBookingRepository.DeleteRange(entity.ProductBookings.Where(d => !dto.ProductBookings.Any(x => x.Id == d.Id))); dto.ProductBookings.ForEach(productBooking => { if (entity.ProductBookings.Count != 0 && productBooking.Id != 0 && entity.ProductBookings.Find(p => p.Id == productBooking.Id) != null) { return; } ProductBooking toAdd = ProductBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, productBooking, currentClient, path); if (toAdd != null) { entity.ProductBookings.Add(toAdd); } }); } if (dto.RoomBookings != null) { RoomBokingRepository.DeleteRange(entity.RoomBookings.Where(d => !dto.RoomBookings.Any(x => x.Id == d.Id))); dto.RoomBookings.ForEach(roomBooking => { if (entity.RoomBookings.Count != 0 && roomBooking.Id != 0 && entity.RoomBookings.Find(p => p.Id == roomBooking.Id) != null) { return; } RoomBooking toAdd = RoomBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, roomBooking, currentClient, path); if (toAdd != null) { entity.RoomBookings.Add(toAdd); } }); } entity.DateCreation = DateTime.UtcNow; return(entity); }