Esempio n. 1
0
        // ---------------------------------------------------------------------
        /// <summary>
        /// Does basic completness/sanity checks on reservation dto. Throws an
        /// InvalidDTOException when any validation check fails. This method must
        /// be used in a try/catch block!
        /// </summary>
        /// <param name="reservationDto"></param>
        public static void ValidateReservationDTO(DTOReservation reservationDto)
        {
            if (reservationDto == null)
            {
                throw new InvalidDTOException("Invalid reservation information supplied (null reference).");
            }

            if (reservationDto.Session == null)
            {
                throw new InvalidDTOException("No session set for this reservation.");
            }

            if (reservationDto.Location == null)
            {
                throw new InvalidDTOException("No parent location.");
            }

            if (reservationDto.Reservables == null)
            {
                throw new InvalidDTOException("No table information supplied.");
            }

            if (reservationDto.Reserver == null)
            {
                throw new InvalidDTOException("No guest information supplied.");
            }
        }
Esempio n. 2
0
        // ---------------------------------------------------------------------
        public static DTOReservation BuildReservationDTO(Reservation r)
        {
            DTOReservation reservationDTO = null;

            if (r != null)
            {
                reservationDTO    = new DTOReservation();
                reservationDTO.Id = r.Id;

                reservationDTO.Reserver = DTOFactory.BuildReserverDTO(r.Reserver);
                reservationDTO.Session  = DTOFactory.BuildSessionDTO(r.Session);

                IList <DTOReservable> dtoReservables = new List <DTOReservable>();
                foreach (Table res in r.ReservedList)
                {
                    dtoReservables.Add(BuildReservableDTO(res, null));
                }
                reservationDTO.Reservables = dtoReservables.ToArray <DTOReservable>();

                reservationDTO.GuestCount        = r.GuestCount;
                reservationDTO.Arrival           = r.Arrival;
                reservationDTO.Duration          = r.Duration;
                reservationDTO.Note              = r.Note;
                reservationDTO.PartyName         = r.PartyName;
                reservationDTO.Released          = r.WhenReleased;
                reservationDTO.Seated            = r.Seated;
                reservationDTO.HasCorrectSeating = r.HasCorrectSeating;
                reservationDTO.Location          = DTOFactory.BuildLocationDTO(r.ParentLocation);
            }
            return(reservationDTO);
        }
Esempio n. 3
0
        public override bool Equals(object obj)
        {
            DTOReservation other = obj as DTOReservation;

            if (other == null)
            {
                return(false);
            }

            return(this.Id == other.Id);
        }
Esempio n. 4
0
        // ---------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="reservationDTO"></param>
        /// <returns></returns>
        public static Reservation ReservationFromDTO(DTOReservation reservationDTO)
        {
            // TODO: validation!

            Reservation reservation = new Reservation();

            reservation.Id         = reservationDTO.Id;
            reservation.Arrival    = reservationDTO.Arrival;
            reservation.GuestCount = reservationDTO.GuestCount;
            reservation.Duration   = reservationDTO.Duration;
            reservation.Note       = reservationDTO.Note;
            reservation.PartyName  = reservationDTO.PartyName;

            foreach (DTOReservable tableDto in reservationDTO.Reservables)
            {
                reservation.ReservedList.Add(DTOHelpers.TableFromDTO(tableDto));
            }


            return(reservation);
        }