예제 #1
0
        public ActionResult Direction(string book_id)
        {
            if (Request.Cookies["user"] != null)
            {
                BookingModel bkm = new BookingModel();
                bkm.book_id = book_id;
                bkm         = bkm.getBookingByBookId();

                if (bkm.lot_id == "" || bkm.lot_id == null)
                {
                    return(RedirectToAction("Map", "Home"));
                }
                else
                {
                    if (getTimeDifference(bkm.tm) > 0.00 && getTimeDifference(bkm.tm) < 2.00)
                    {
                        ViewBag.LotId  = bkm.lot_id;
                        ViewBag.BookId = book_id;
                        return(View());
                    }
                    else
                    {
                        bkm.book_id = book_id;
                        bkm.deleteBooking();
                        return(RedirectToAction("Map", "Home"));
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
예제 #2
0
        public ActionResult CheckIn(string lot_id, string card_number)
        {
            string    response = "";
            UserModel user     = new UserModel();

            user.card_number = card_number;
            if (user.checkIfCardExists() < 1)
            {
                response = "500";
            }
            else
            {
                user = user.getUserByCard();
                string       user_id = user.user_id;
                DateTime     now     = DateTime.Now;
                BookingModel bkm     = new BookingModel();
                bkm.lot_id  = lot_id;
                bkm.user_id = user_id;
                bkm.day     = now.ToString("dd/MM/yyyy");
                bkm.status  = "0";
                int countBookings = bkm.getAllBookingByLotUserDayStatus().Count();

                if (!(countBookings < 1))
                {
                    LogModel lgm = new LogModel();
                    lgm.lot_id     = lot_id;
                    lgm.user_id    = user_id;
                    lgm.day        = now.ToString("dd/MM/yyyy");
                    lgm.out_time   = "0000AMPM";
                    lgm.pay_status = "0";

                    if (!(lgm.getAllLogsbyLotUserDayOutTime().Count() > 0))
                    {
                        lgm.in_time = now.ToString("hh:mm:ss tt");
                        lgm.addLog();
                        bkm = bkm.getAllBookingByLotUserDayStatus()[0];
                        bkm.deleteBooking();
                        response = "200";
                    }
                    else
                    {
                        response = "500";
                    }
                }
                else
                {
                    response = "500";
                }
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }