示例#1
0
 public void Init()
 {
     ctx  = EFContext.CreateContext();
     repo = new PeopleBookingRepository(ctx);
 }
 public void Init()
 {
     ctx = EFContext.CreateContext();
     repo = new PeopleBookingRepository(ctx);
 }
示例#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);
        }