Ejemplo n.º 1
0
        /// <summary>
        /// Add appointment to queue list
        /// </summary>
        /// <param name="date"></param>
        /// <param name="did"></param>
        /// <returns></returns>
        public ActionResult QueueSelect(DateTime date, string did) // add the patient (update) turn to queue
        {
            //Session["UserLoggedID"]
            if (verifyUser() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            Queue queTemp = new Queue();

            queTemp.date = date;
            queTemp.DID  = did;
            queTemp.PID  = Session["UserLoggedIn"].ToString();
            queTemp.mode = false;

            using (var db = new QueueDAL())
            {
                db.Queues.Attach(queTemp);
                db.Entry(queTemp).Property(x => x.PID).IsModified  = true;
                db.Entry(queTemp).Property(x => x.mode).IsModified = true;
                db.SaveChanges();
            }


            //que.Queues.Add(queTemp);
            //que.SaveChanges();


            return(RedirectToAction("ViewAppointments", "User"));
        }
Ejemplo n.º 2
0
        public ActionResult QueueAdd(Queue que)
        {
            //verify
            if (Session["DoctorLoggedIn"].ToString() != que.DID)
            {
                TempData["UnknownUser"] = "******";
                return(RedirectToAction("ShowAppointments", "Doctor"));
            }
            if (verifyDoctor() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            if (que.PID != null)
            {
                if (verifyPatient(que.PID.ToString()) == false)
                {
                    TempData["UnknownUser"] = "******";
                    return(RedirectToAction("ShowAppointments", "Doctor"));
                }
            }
            if (ModelState.IsValid)
            {
                QueueDAL queDAL = new QueueDAL();

                try
                {
                    //Add and save queue.
                    queDAL.Queues.Attach(que);
                    queDAL.Queues.Add(que);
                    queDAL.SaveChanges();
                    Session["DuplicateQueue"] = null;
                    List <Queue> objQueues = queDAL.Queues.ToList <Queue>();
                    //que = new Queue();
                    //return Json(Url.Action("ShowAppointments", "Doctor"));
                    return(Json(objQueues, JsonRequestBehavior.AllowGet));
                    //return RedirectToAction("ShowAppointments", "Doctor");
                }
                catch (Exception)
                {
                    queDAL.Queues.Remove(que);
                    Session["DuplicateQueue"] = true;
                    List <Queue> objQueues = queDAL.Queues.ToList <Queue>();
                    //que = new Queue();
                    return(Json(objQueues, JsonRequestBehavior.AllowGet));

                    //return RedirectToAction("ShowAppointments", "Doctor");
                }
            }
            Session["DuplicateQueue"] = null;
            QueueDAL     queDAL2    = new QueueDAL();
            List <Queue> objQueues2 = queDAL2.Queues.ToList <Queue>();

            //return RedirectToAction("ShowAppointments", "Doctor");
            //que = new Queue();
            return(Json(objQueues2, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public VMQueue getQueueVM()
        {
            QueueDAL     que   = new QueueDAL();
            List <Queue> ques  = que.Queues.ToList <Queue>();
            VMQueue      vmQue = new VMQueue();

            vmQue.queues = ques;
            //ViewBag.QueueList = ques;
            return(vmQue);
        }
Ejemplo n.º 4
0
        public ActionResult GetQueuesByJson()
        {
            if (verifyDoctor() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            QueueDAL     dal       = new QueueDAL();
            List <Queue> objQueues = dal.Queues.ToList <Queue>();

            return(Json(objQueues, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Method to show current doctors.
        /// </summary>
        /// <returns></returns>
        public ActionResult ShowQueues()
        {
            if (verifyAdmin() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            QueueDAL queDAL = new QueueDAL();
            VMQueue  queVM  = new VMQueue();

            queVM.queues = queDAL.Queues.ToList <Queue>();
            return(View(queVM));
        }
Ejemplo n.º 6
0
        // GET: Doctor
        /// <summary>
        /// Method to show the doctor all the appointments
        /// </summary>
        /// <returns></returns>
        public ActionResult ShowAppointments()
        {
            if (verifyDoctor() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            QueueDAL que = new QueueDAL();


            string       docID    = Session["DoctorLoggedIn"].ToString();
            List <Queue> queueOBJ = (from x in que.Queues where x.DID.Equals(docID) select x).ToList <Queue>();

            ViewBag.QueueList = queueOBJ;

            //return Json(queueOBJ, JsonRequestBehavior.AllowGet);
            return(View());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Method to delete a queue.
        /// </summary>
        /// <param name="date"></param>
        /// <param name="did"></param>
        /// <param name="mode"></param>
        /// <param name="pid"></param>
        /// <returns></returns>
        public ActionResult QueueDelete(DateTime date, string did, bool mode, string pid)
        {
            //verify the doctor
            if (verifyDoctor() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            //open connection to dbo.tblDoctors DB.
            QueueDAL que = new QueueDAL();


            Queue queTemp = new Queue();

            queTemp.date = date;
            queTemp.DID  = did;
            queTemp.mode = mode;
            queTemp.PID  = pid;
            que.Queues.Attach(queTemp);
            que.Queues.Remove(queTemp);
            que.SaveChanges();
            return(RedirectToAction("ShowAppointments", "Doctor"));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Add appointment to queue list
        /// </summary>
        /// <param name="date"></param>
        /// <param name="did"></param>
        /// <returns></returns>
        public ActionResult QueueSelect(DateTime date, string did) // add the patient (update) turn to queue
        {
            //Session["UserLoggedID"]
            if (verifyUser() == false)
            {
                /*
                 * verifing current user
                 */
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }

            /*
             * Create the connection to DB.Queue
             * and make an object with current data
             */
            QueueDAL tempDAL = new QueueDAL();
            Queue    queTemp = new Queue();

            queTemp.date = date;
            queTemp.DID  = did;
            queTemp.PID  = Session["UserLoggedIn"].ToString();
            queTemp.mode = false;

            using (var db = new QueueDAL())
            {
                try
                {
                    /*
                     * We're looking to see if there is a line of data with 'mode'==0 with current DID and date
                     */
                    List <Queue> queueTemp = (from x in tempDAL.Queues where x.mode.Equals(false) && x.date.Equals(date) && x.DID.Equals(did) select x).ToList <Queue>();
                    if (queueTemp.Count() == 0)
                    {
                        /*
                         * if there isn't a taken line-->update the DB (transaction completed)
                         */
                        db.Queues.Attach(queTemp);
                        db.Entry(queTemp).Property(x => x.PID).IsModified  = true;
                        db.Entry(queTemp).Property(x => x.mode).IsModified = true;
                        db.SaveChanges();
                    }
                    else
                    {
                        /*
                         * Else show error message
                         */
                        TempData["WarningMessage"] = "Error selecting the Queue,please try again.";
                        return(RedirectToAction("ViewAppointments", "User"));
                    }
                }
                catch (Exception e)
                {
                    /*
                     * Error message in case of failed connection
                     */
                    TempData["WarningMessage"] = e;
                    return(RedirectToAction("ViewAppointments", "User"));
                }
            }

            return(RedirectToAction("ViewAppointments", "User"));
        }