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; }
public bool checkWashTime(Reservation r) { bool resAfterTime = false; if (DateTime.Today == r.reservationDate) { resAfterTime = (DateTime.Today + fromTime) < (DateTime.Now); } return resAfterTime; }
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); }
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; }
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); }