Пример #1
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));
        }