public LaundryRoom InitializeLaundryRoom() { LaundryRoom laundryRoom = new LaundryRoom(); Washer washer1 = new Washer(1, "1", "open"); Washer washer2 = new Washer(2, "2", "open"); Washer washer3 = new Washer(3, "3", "busy"); Washer washer4 = new Washer(4, "4", "idle"); Washer washer5 = new Washer(5, "5", "open"); List <Washer> washerList = new List <Washer>(); washerList.Add(washer1); washerList.Add(washer2); washerList.Add(washer3); washerList.Add(washer4); washerList.Add(washer5); Dryer dryer1 = new Dryer(1, "1", "open"); Dryer dryer2 = new Dryer(2, "2", "busy"); Dryer dryer3 = new Dryer(3, "3", "idle"); Dryer dryer4 = new Dryer(4, "4", "open"); Dryer dryer5 = new Dryer(5, "5", "idle"); List <Dryer> dryerList = new List <Dryer>(); dryerList.Add(dryer1); dryerList.Add(dryer2); dryerList.Add(dryer3); dryerList.Add(dryer4); dryerList.Add(dryer5); laundryRoom.washerList = washerList; laundryRoom.dryerList = dryerList; return(laundryRoom); }
// GET: Kiosk public ActionResult Index() { HomeController home = new HomeController(); LaundryRoom laundryRoom = home.InitializeLaundryRoom(); return(View(laundryRoom)); }
public static LaundryUser CreateLaundryUser(LaundryRoom laundryRoom, String name) { LaundryUser tempLaundryUser = null; try { tempLaundryUser = new LaundryUser(); tempLaundryUser.LaundryRoom1 = laundryRoom; tempLaundryUser.name = name; Db.LaundryUsers.Add(tempLaundryUser); Db.SaveChanges(); } catch (DbUpdateException) { throw new Exception("There is already a user named: " + tempLaundryUser.name); } return tempLaundryUser; }
public static LaundryUser CreateLaundryUser(LaundryRoom laundryRoom, String name) { LaundryUser tempLaundryUser = null; try { tempLaundryUser = new LaundryUser(); tempLaundryUser.LaundryRoom1 = laundryRoom; tempLaundryUser.name = name; Db.LaundryUsers.Add(tempLaundryUser); Db.SaveChanges(); } catch (DbUpdateException) { throw new Exception("There is already a user named: " + tempLaundryUser.name); } return(tempLaundryUser); }
public void TestData() { LaundryRoom = new LaundryRoom(); LaundryRoom.name = "laundryroom 1"; LaundryRoom.maxReservationPerUser = 456; Machine machine1 = new Machine(); machine1.LaundryRoom1 = LaundryRoom; machine1.machineType = "TestVaskemaskine"; machine1.timesUsed = 0; machine1.broken = false; Machine machine2 = new Machine(); machine2.LaundryRoom1 = LaundryRoom; machine2.machineType = "TestVaskemaskine"; machine2.timesUsed = 0; machine2.broken = false; Machine machine3 = new Machine(); machine3.LaundryRoom1 = LaundryRoom; machine3.machineType = "TestVaskemaskine"; machine3.timesUsed = 0; machine3.broken = false; LaundryUser = new LaundryUser(); LaundryUser.name = "Eunji1"; LaundryUser.LaundryRoom1 = LaundryRoom; Reservation r1 = new Reservation(); r1.reservationDate = new DateTime(2015, 01, 05); r1.LaundryUser1 = LaundryUser; r1.Machines.Add(machine1); r1.Machines.Add(machine2); Reservation r2 = new Reservation(); r2.reservationDate = new DateTime(2016, 12, 04); r2.LaundryUser1 = LaundryUser; r2.Machines.Add(machine1); Reservation r3 = new Reservation(); r3.reservationDate = new DateTime(2016, 12, 03); r3.LaundryUser1 = LaundryUser; r3.Machines.Add(machine1); r3.Machines.Add(machine3); Reservation r4 = new Reservation(); r4.reservationDate = new DateTime(2015, 01, 03); r4.LaundryUser1 = LaundryUser; r4.Machines.Add(machine1); r4.Machines.Add(machine3); try { _db.LaundryRooms.Add(LaundryRoom); _db.LaundryUsers.Add(LaundryUser); _db.Machines.Add(machine1); _db.Machines.Add(machine2); _db.Machines.Add(machine3); _db.Reservations.Add(r1); _db.Reservations.Add(r2); _db.Reservations.Add(r3); _db.Reservations.Add(r4); _db.SaveChanges(); } catch (DbUpdateException e) { Console.WriteLine(e.InnerException); } }
//anvender timesUsed på machine public int TotalResMachine2(LaundryRoom laundryRoom) { return(laundryRoom.Machines.Sum(machine => machine.timesUsed.GetValueOrDefault())); }
//anvender de reservationer der er i systemet public int TotalResMachine(LaundryRoom laundryRoom) { return((from laundryUser in laundryRoom.LaundryUsers from reservation in laundryUser.Reservations from m in reservation.Machines select m).Count()); }
public static List<LaundryUser> GetUsers(LaundryRoom laundryRoom) { return laundryRoom.LaundryUsers.ToList(); }
public static List <LaundryUser> GetUsers(LaundryRoom laundryRoom) { return(laundryRoom.LaundryUsers.ToList()); }
//anvender timesUsed på machine public int TotalResMachine2(LaundryRoom laundryRoom) { return laundryRoom.Machines.Sum(machine => machine.timesUsed.GetValueOrDefault()); }
//anvender de reservationer der er i systemet public int TotalResMachine(LaundryRoom laundryRoom) { return (from laundryUser in laundryRoom.LaundryUsers from reservation in laundryUser.Reservations from m in reservation.Machines select m).Count(); }