Esempio n. 1
0
        public ActionResult GetEscapeRoom(int id)
        {
            EscapeRoomService ecss = new EscapeRoomService();
            EscapeRoom        escr = ecss.GetEscapeRoom(id);

            return(View(escr));
        }
Esempio n. 2
0
        public ActionResult CreateBookingCheck(int id, DateTime BDate)
        {
            EscapeRoomService escs = new EscapeRoomService();

            EscRef.EscapeRoom es = escs.GetEscapeRoom(id);
            ViewBag.EscapeRoom = es;
            List <TimeSpan> freetime = escs.FreeTimes(id, BDate);

            if (BDate == null)
            {
                TempData["message"] = "Der er ikke valgt en dato";
                return(RedirectToAction("CreateBooking", new { id = id }));
            }
            else if (freetime.Count == 0)
            {
                TempData["message"] = "Der ingen tilgængelige booking tider";
                return(RedirectToAction("CreateBooking", new { id = id }));
            }
            else
            {
                ViewBag.freetimes  = freetime;
                ViewBag.ChosenDate = BDate.ToString("dd-MM-yyyy");
            }

            return(View());
        }
Esempio n. 3
0
        /// <summary>
        ///  Gets an escaperoom
        /// </summary>
        /// <param name="id">The EscapeRoom ID</param>
        /// <returns>returns the View GetEscapeRoom</returns>
        public ActionResult GetEscapeRoom(int id)
        {
            EscapeRoomService ecss = new EscapeRoomService();

            EscRef.EscapeRoom escr = ecss.GetEscapeRoom(id);
            ViewBag.Escaperoom1 = escr;
            return(View());
        }
Esempio n. 4
0
        /// <summary>
        /// Starts the booking by getting the escaperoom with the id
        /// </summary>
        /// <param name="id">The EscapeRoom ID</param>
        /// <returns>Returns the view CreateBooking if customer is logged in and redirects to login if not</returns>
        public ActionResult CreateBooking(int id)
        {
            EscapeRoomService escs = new EscapeRoomService();

            EscRef.EscapeRoom es = escs.GetEscapeRoom(id);
            ViewBag.TimeList   = es.AvalibleTimes;
            ViewBag.EscapeRoom = es;
            HttpCookie cookie = Request.Cookies["User"];

            if (cookie == null)
            {
                return(RedirectToAction("Login", "Customer"));
            }

            return(View());
        }
Esempio n. 5
0
        public ActionResult CreateBookingDone(int EmployeeID, string username, int escapeRoomID, TimeSpan BookTime, int AmountOfPeople, DateTime BDate)
        {
            EscapeRoomService escs = new EscapeRoomService();

            EscRef.EscapeRoom es = escs.GetEscapeRoom(escapeRoomID);
            ViewBag.EscapeRoom = es;
            List <TimeSpan> freetime = escs.FreeTimes(escapeRoomID, BDate);

            ViewBag.freetimes = freetime;
            BookingService bs     = new BookingService();
            HttpCookie     cookie = Request.Cookies["User"];

            cookie.Value = username;

            int c = bs.CreateBooking(EmployeeID, username, escapeRoomID, BookTime, AmountOfPeople, BDate);

            if (c == 0)
            {
                TempData["message"] = "Den tid du prøvede at booke er desværre blevet taget ";
                return(RedirectToAction("CreateBooking", new { id = escapeRoomID }));
            }
            return(View());
        }
Esempio n. 6
0
        public void CreateNewBookingTest( )
        {
            //Arrange
            BookingService    bs  = new BookingService();
            CustomerService   cs  = new CustomerService();
            EscapeRoomService es  = new EscapeRoomService();
            EmployeeService   ems = new EmployeeService();

            MAPMA_WebClient.CusRef.Customer   cus = cs.GetCustomer("Anorak");
            MAPMA_WebClient.EmpRef.Employee   em  = ems.GetEmployee(1);
            MAPMA_WebClient.EscRef.EscapeRoom er  = es.GetEscapeRoom(1);
            Customer customer = new Customer()
            {
                customerNo = cus.customerNo,
                firstName  = cus.firstName,
                lastName   = cus.lastName,
                mail       = cus.mail,
                password   = cus.password,
                phone      = cus.phone,
                username   = cus.username
            };
            Employee employee = new Employee()
            {
                address    = em.address,
                cityName   = em.cityName,
                employeeID = em.employeeID,
                firstName  = em.firstName,
                lastName   = em.lastName,
                mail       = em.mail,
                phone      = em.phone,
                region     = em.region,
                zipcode    = em.zipcode
            };
            EscapeRoom escapeRoom = new EscapeRoom()
            {
                cleanTime    = er.cleanTime,
                description  = er.description,
                escapeRoomID = er.escapeRoomID,
                maxClearTime = er.maxClearTime,
                name         = er.name,
                price        = er.price,
                rating       = er.rating
            };
            Booking hostBook;
            Booking book = new Booking()
            {
                amountOfPeople = 22,
                bookingTime    = DateTime.Now.TimeOfDay,
                cus            = customer,
                date           = DateTime.Now.AddDays(7.0).Date,
                emp            = employee,
                er             = escapeRoom
            };


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

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

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