Beispiel #1
0
        public static Reservation CreateReservation(ReservationDto reservationDto)
        {
            var reservation = new Reservation();

            reservation.BookInDate      = reservationDto.BookInDate;
            reservation.BookOutDate     = reservationDto.BookOutDate;
            reservation.Commission      = reservationDto.Commission;
            reservation.CreationDate    = reservationDto.CreationDate;
            reservation.Currency        = reservationDto.Currency;
            reservation.Id              = reservationDto.Id;
            reservation.Price           = reservationDto.Price;
            reservation.ReservationCode = reservationDto.ReservationCode;
            reservation.Source          = reservationDto.Source;

            var guests = new List <ReservationGuest>();

            foreach (var guestDto in reservationDto.Guests)
            {
                guests.Add(new ReservationGuest()
                {
                    Guest = GuestDto.CreateGuest(guestDto)
                });
            }

            reservation.ReservationsGuests = guests;

            return(reservation);
        }
Beispiel #2
0
        public static List <ReservationDto> CreateManyReservationDto(IEnumerable <Reservation> reservations)
        {
            var reservationsDto = new List <ReservationDto>();

            foreach (var reservation in reservations)
            {
                var dto = CreateReservationDto(reservation);
                dto.Guests =
                    GuestDto.CreateManyGuestDto(reservation.ReservationsGuests.Select(rg => rg.Guest).ToList());
                reservationsDto.Add(dto);
            }

            return(reservationsDto);
        }
Beispiel #3
0
        public static Guest CreateGuest(GuestDto guestDto)
        {
            var guest = new Guest();

            guest.Id         = guestDto.Id;
            guest.FirstName  = guestDto.FirstName;
            guest.LastName   = guestDto.LastName;
            guest.Address    = guestDto.Address;
            guest.BirthDate  = guestDto.BirthDate;
            guest.City       = guestDto.City;
            guest.Email      = guestDto.Email;
            guest.PostalCode = guestDto.PostalCode;
            guest.Telephone  = guestDto.Telephone;

            return(guest);
        }
Beispiel #4
0
        public static GuestDto CreateGuestDto(Guest guest, bool addReservations = false)
        {
            var dto = new GuestDto();

            dto.Id         = guest.Id;
            dto.FirstName  = guest.FirstName;
            dto.LastName   = guest.LastName;
            dto.Address    = guest.Address;
            dto.BirthDate  = guest.BirthDate;
            dto.City       = guest.City;
            dto.Email      = guest.Email;
            dto.PostalCode = guest.PostalCode;
            dto.Telephone  = guest.Telephone;

            if (addReservations == true)
            {
                dto.Reservations = guest.GuestReservations.ToList();
            }

            return(dto);
        }