Esempio n. 1
0
        public List<Machine> FindMachinesAvailable(Reservation reservation)
        {
            List<Machine> machines = Machines.ToList();

            foreach (var m in Machines)
            {
                if (!m.broken.GetValueOrDefault())
                {
                    foreach (var res in m.Reservations)
                    {

                        if ((res.reservationDate.GetValueOrDefault().Date == reservation.reservationDate.GetValueOrDefault().Date &&
                             res.WashTime == reservation.WashTime && !res.inactive.GetValueOrDefault()) ||
                            checkIfMaxRes(reservation.LaundryUser1))
                        {
                            if (machines.Contains(m))
                            {
                                machines.Remove(m);
                            }
                        }
                    }
                }
                else
                {
                    if (machines.Contains(m))
                    {
                        machines.Remove(m);
                    }
                }
            }

            return machines;
        }
Esempio n. 2
0
 public bool checkWashTime(Reservation r)
 {
     bool resAfterTime = false;
     if (DateTime.Today == r.reservationDate)
     {
         resAfterTime = (DateTime.Today + fromTime) <
                        (DateTime.Now);
     }
     return resAfterTime;
 }
Esempio n. 3
0
        public void Init()
        {
            laundryRoom = new LaundryRoom();
            laundryRoom.Machines.Add(new Machine());
            laundryRoom.Machines.Add(new Machine());
            laundryRoom.Machines.Add(new Machine());
            laundryUser      = new LaundryUser();
            laundryUser.name = "Namjoo";

            reservation = new Reservation();

            washTime          = new WashTime();
            washTime.fromTime = DateTime.Now.AddMinutes(10).TimeOfDay;

            reservation.WashTime1 = washTime;
            laundryUser.Reservations.Add(reservation);
        }
Esempio n. 4
0
        public void Init()
        {
            laundryRoom = new LaundryRoom();
            laundryRoom.Machines.Add(new Machine());
            laundryRoom.Machines.Add(new Machine());
            laundryRoom.Machines.Add(new Machine());
            laundryUser = new LaundryUser();
            laundryUser.name = "Namjoo";

            reservation = new Reservation();

            washTime = new WashTime();
            washTime.fromTime = DateTime.Now.AddMinutes(10).TimeOfDay;

            reservation.WashTime1 = washTime;
            laundryUser.Reservations.Add(reservation);
        }
Esempio n. 5
0
        public int TimeLeft(Reservation resdate)
        {
            int timeLeft = 0;

            if (
                resdate.reservationDate.GetValueOrDefault()
                    .AddMinutes(this.programTime.GetValueOrDefault())
                    .Subtract(DateTime.Now)
                    .Minutes > 0)
            {
                timeLeft = resdate.reservationDate.GetValueOrDefault().AddMinutes(this.programTime.GetValueOrDefault()).Subtract(DateTime.Now).Minutes;
            }
            else
            {
                Machine1.start = false;
                timeLeft = 0;
            }

            return timeLeft;
        }
Esempio n. 6
0
        public void TestGetFutureRes()
        {
            reservation.reservationDate = DateTime.Today;
            Reservation futureReservation = new Reservation();
            futureReservation.reservationDate = DateTime.Today.AddDays(7);
            laundryUser.Reservations.Add(futureReservation);

            Assert.AreEqual(1, laundryUser.GetFutureRes().Count);
        }