Пример #1
0
 public Reservation(Guid id, AbstractPlace place, DateTime date, int period)
     : base(id)
 {
     Place             = place;
     StartDate         = date;
     ReservationPeriod = period;
 }
Пример #2
0
        public bool CanReserve(AbstractPlace place, DateTime date, int period)
        {
            foreach (Reservation reserv in _resrvations)
            {
                if (reserv.Place == place)
                {
                    DateTime tmp1 = reserv.StartDate;
                    DateTime tmp2 = date;

                    while (tmp1 <= reserv.StartDate.AddDays(reserv.ReservationPeriod) |
                           tmp2 <= tmp2.AddDays(period))
                    {
                        if (tmp1 == tmp2)
                        {
                            return(false);
                        }

                        tmp1 = tmp1.AddDays(1);
                        tmp2 = tmp2.AddDays(2);
                    }
                }
            }

            return(true);
        }