Exemple #1
0
        public void CreateBooking( )
        {
            IBookingServices     bs  = new BookingServices();
            ICustomerServices    cs  = new CustomerServices();
            IEscapeRoom_Services es  = new EscapeRoom_Services();
            IEmplyeeServices     ems = new EmplyeeServices();

            ModelLayer.Customer   cus = cs.Get("Anorak");
            ModelLayer.Employee   em  = ems.Get(1);
            ModelLayer.EscapeRoom er  = es.GetForOwner(1);
            Booking hostBook;
            Booking book = new Booking()
            {
                amountOfPeople = 22,
                bookingTime    = new TimeSpan(16, 00, 0000),
                cus            = cus,
                date           = DateTime.Now.AddDays(7.0).Date,
                emp            = em,
                er             = er
            };


            //Act
            bs.Create(book.emp.employeeID, book.cus.username, book.er.escapeRoomID, book.bookingTime, book.amountOfPeople, book.date);
            hostBook = bs.Get(book.er.escapeRoomID, book.cus.username, book.date);

            //Assert
            Assert.AreEqual(book.date.Date, hostBook.date.Date);
            Assert.AreEqual(book.emp.employeeID, hostBook.emp.employeeID);
            Assert.AreEqual(book.cus.username, hostBook.cus.username);

            bs.Delete(book.emp.employeeID, book.cus.username, book.er.escapeRoomID, book.bookingTime, book.amountOfPeople, book.date);

            Assert.IsNull(bs.Get(book.er.escapeRoomID, book.cus.username, book.date).cus);
        }
 public Reservation(Employee employee, Machine machine, DateTime day, DateTime start, DateTime end,
                    string jamType, string description = "", int id = 0 )
 {
     this.Id				= id;
     this.User			= employee;
     this.Machine		= machine;
     this.Day			= day;
     this.Start			= start;
     this.End			= end;
     this.JamType		= jamType;
     this.Description	= description;
 }
        public static List<IEmployee> GetEmployees()
        {
            List<EmployeeEntity> employeeEntityList		= Persistens.GetAllEomployeeEntities();
            List<IEmployee> employeeList				= new List<IEmployee>();

            foreach (EmployeeEntity employeeEntity in employeeEntityList) {
                IEmployee	employee = new Employee(employeeEntity.Id, employeeEntity.Name, employeeEntity.Experience);
                            employeeList.Add(employee);
            }

            return employeeList;
        }
        public static List<IReservation> GetReservations()
        {
            List<IReservation> reservationsList = new List<IReservation>();
                List<IEmployee> employeeList = GetEmployees();
                List<IMachine> machineList = GetMachines();
                List<ReservationEntity> reservationEntityList = Persistens.GetAllReservationEntities();

                foreach (ReservationEntity reservationEntity in reservationEntityList)
                {
                    IMachine machineFromList = null;
                    IEmployee employeeFromList = null;
                    foreach (IMachine machine in machineList)
                    {
                        if (machine.Id == reservationEntity.Machine)
                        {
                            machineFromList = machine;
                        }
                    }

                    foreach (IEmployee employee in employeeList)
                    {
                        if (employee.Id == reservationEntity.User)
                        {
                            employeeFromList = employee;
                        }
                    }

                    Machine mac = new Machine(machineFromList.Name, machineFromList.Type, machineFromList.Status, machineFromList.Id);
                    Employee emp = new Employee(employeeFromList.Id, employeeFromList.Name, employeeFromList.Experience);

                    IReservation res = new Reservation(emp, mac, reservationEntity.Day, reservationEntity.Start,
                                             reservationEntity.End, reservationEntity.JamType, reservationEntity.Description, reservationEntity.Id);
                    reservationsList.Add(res);
                }
                return reservationsList;
        }