public static IReservation GetReservation(int reservationId, Guest guest, Room room, DateTime checkIn, DateTime checkOut, int noOfPets, double totalPrice, string additionalInfo, int noOfGuests, int noOfAdults, int noOfChildren, DateTime dateBooked, string status, CreditCard creditCard)
 {
     if (_reservation != null)  // ie is Factory is primed with an object.
         return _reservation;
     else
         return new Reservation(reservationId, guest, room, checkIn, checkOut, noOfPets, totalPrice, additionalInfo, noOfGuests, noOfAdults, noOfChildren, dateBooked, status, creditCard); // Factory coughs up a regular user (for production code)
 }
 public Reservation(Guest guest, Room room, DateTime checkIn, DateTime checkOut, int noOfPets, double totalPrice, string additionalInfo, int noOfGuests, DateTime dateBooked, string status, int reservationId, CreditCard creditCard)
 {
     this._guest = guest;
     this._room = room;
     this._checkIn = checkIn;
     this._checkOut = checkOut;
     this._noOfPets = noOfPets;
     this._totalPrice = totalPrice;
     this._additionalInfo = additionalInfo;
     this._noOfGuests = noOfGuests;
     this._dateBooked = dateBooked;
     this._status = status;
     this._reservationId = reservationId;
     this._creditCard = creditCard;
 }
 public Reservation(int reservationId, Guest guest, Room room, DateTime checkIn, DateTime checkOut, int noOfPets, double totalPrice, string additionalInfo, int noOfGuests, int noOfAdults, int noOfChildren, DateTime dateBooked, string status, CreditCard creditCard)
 {
     _reservationId = reservationId;
     _guest = guest;
     _room = room;
     _checkIn = checkIn;
     _checkOut = checkOut;
     _noOfPets = noOfPets;
     _totalPrice = totalPrice;
     _additionalInfo = additionalInfo;
     _noOfGuests = noOfGuests;
     _noOfAdults = noOfAdults;
     _noOfChildren = noOfChildren;
     _dateBooked = dateBooked;
     _status = status;
     _creditCard = creditCard;
 }
        public Boolean addNewReservation(Guest guest, Room room, DateTime checkIn, DateTime checkOut, int noOfPets, double totalPrice,
                    string additionalInfo, int noOfGuests, int noOfAdults, int noOfChildren, DateTime dateBooked, string status, CreditCard creditCard)
        {
            // some validation on userName, we won't allow duplicate usernames. Business rule
                    IReservation duplicateReservation =
                        this._reservationList.FirstOrDefault(
                            reservation => reservation.Guest.GuestId == guest.GuestId && reservation.CheckIn == checkIn);
                    /* provides a shortcut to accessing the element that occurs first in the collection or query,
            while protecting against invalid accesses if there are no elements.It'sa linq query. FirstOrDefault is a generic method which means it accepts a type parameter that indicates what types it acts upon.
            The => is a lambda operator. Anything before the => are the input parameters, and anything after is the expression. You can have multiple input parameters.
            Think of a lambda expression as"given x, do something with x" * */
                    if (duplicateReservation != null)
                        return false;
                    else
                    {
                        try
                        {
                            //if (UserName.Length < 5) // Won't allow usernames with less than 5 characters. Business Rule
                            //    return false; // Maybe other rules on Usernames such as some Uppercase etc
                            ////  if (password.Length < 5)// Won't allow passwords with less than 5 characters. Business Rule
                            ////       return false; // Maybe password policy such as at least one Upper case, one number etc see
                            //// see Regex - regular expressions

                            int maxId = 0;

                            // maybe add some logic (busiess rules) about password policy
                            // IUser user = new User(name, password, userType); // Construct a User Object
                            foreach (var reservation1 in _reservationList)
                            {
                                var reservation = (Reservation) reservation1;
                                if (reservation.ReservationId > maxId)
                                    maxId = reservation.ReservationId;
                            }
                            IReservation theReservation = ReservationFactory.GetReservation(maxId + 1, guest, room, checkIn,
                                checkOut, noOfPets, totalPrice, additionalInfo, noOfGuests, noOfAdults, noOfChildren, dateBooked, status, creditCard);
                                // Using a Factory to create the user entity object. ie seperating object creation from business logic
                            _reservationList.Add(theReservation);
                                // Add a reference to the newly created object to the Models UserList
                            DataLayer.addNewReservationToDb(theReservation);
                                //Gets the DataLayer to add the new user to the DB.
                            return true;
                        }
                        catch (System.Exception excep)
                        {
                            return false;
                        }
                    }
        }