コード例 #1
0
        public bool InsertAppointment(Apointment obj)
        {
            _command.CommandText = "sp_InsertAppointment";
            _command.Parameters.Clear();
            _command.CommandType = System.Data.CommandType.StoredProcedure;
            _command.Parameters.Add(new SqlParameter("@date", obj.Date));
            _command.Parameters.Add(new SqlParameter("@doctorId", obj.DoktorId));
            _command.Parameters.Add(new SqlParameter("@status", obj.Status));
            _command.Parameters.Add(new SqlParameter("@patientId", obj.PatientId));
            _command.Parameters.Add(new SqlParameter("@session", obj.Session));

            try
            {
                if (_command.Connection.State == System.Data.ConnectionState.Closed)
                {
                    _command.Connection.Open();
                }
                int result = _command.ExecuteNonQuery();
                return(result > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { _command.Connection.Close(); }
        }
コード例 #2
0
        // GET: Apointment/Edit/5
        public ActionResult Edit(int?id, int?p)
        {
            if (Session["Palogin"].ToString() == "")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (((Models.Patient)Session["Pa"]).Id != p)
            {
                Session["Msg"] = "You Have No Information";
                return(RedirectToAction("Index"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Apointment apointment = db.Apointments.Find(id);

            if (apointment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DoctorId  = new SelectList(db.Doctors, "Id", "Name", apointment.DoctorId);
            ViewBag.PatientId = new SelectList(db.Patients, "Id", "Name", apointment.PatientId);
            return(View(apointment));
        }
コード例 #3
0
        // GET: Apointment/Details/5
        public ActionResult Details(int?id, int?p, int?d)
        {
            if (Session["Palogin"].ToString() == "" && Session["Dologin"].ToString() == "")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Apointment apointment = db.Apointments.Find(id);

            if (apointment == null)
            {
                return(HttpNotFound());
            }
            if (((Models.Doctor)Session["Do"]).Id == d)
            {
                Session["Msg"] = "";
                return(View(apointment));
            }
            if (((Models.Patient)Session["Pa"]).Id == p)
            {
                Session["Msg"] = "";
                return(View(apointment));
            }
            Session["Msg"] = "No Information For You";
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Apointment apointment = db.Apointments.Find(id);

            db.Apointments.Remove(apointment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public async Task <IHttpActionResult> Add([FromBody] Apointment entity)
        {
            DataContext.Apointment.Add(entity);
            await DataContext.SaveChangesAsync();

            return(Json(new ResponseData <Apointment>()
            {
                Data = entity
            }));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "Id,DoctorId,PatientId,ProblemName")] Apointment apointment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(apointment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DoctorId  = new SelectList(db.Doctors, "Id", "Name", apointment.DoctorId);
     ViewBag.PatientId = new SelectList(db.Patients, "Id", "Name", apointment.PatientId);
     return(View(apointment));
 }
コード例 #7
0
        public ActionResult Create([Bind(Include = "Id,DoctorId,PatientId,ProblemName")] Apointment apointment, int p, int d)
        {
            if (ModelState.IsValid)
            {
                apointment.DoctorId  = d;
                apointment.PatientId = p;
                db.Apointments.Add(apointment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(apointment));
        }
コード例 #8
0
 public ActionResult Appointment(Apointment ap)
 {
     if (ModelState.IsValid)
     {
         using (Database1Entities1 db = new Database1Entities1())
         {
             db.Apointments.Add(ap);
             db.SaveChanges();
             ModelState.Clear();
             ap = null;
             ViewBag.Message = "Doctor Information Updated";
         }
     }
     return(View());
 }
コード例 #9
0
        public List <Apointment> GetAllAppointment()
        {
            List <Apointment> listAppointment = null;
            Apointment        appointment;

            _command.CommandText = "sp_GetAllAppointmet";
            _command.CommandType = System.Data.CommandType.StoredProcedure;
            _command.Parameters.Clear();

            try
            {
                if (_command.Connection.State == System.Data.ConnectionState.Closed)
                {
                    _command.Connection.Open();
                }
                SqlDataReader dr = _command.ExecuteReader();
                if (dr.HasRows)
                {
                    listAppointment = new List <Apointment>();
                    while (dr.Read())
                    {
                        appointment           = new Apointment();
                        appointment.Id        = (int)dr[0];
                        appointment.PatientId = (int)dr[1];
                        appointment.DoktorId  = (int)dr[2];
                        appointment.Date      = (DateTime)dr[3];
                        appointment.Session   = (TimeSpan)dr[4];
                        appointment.Status    = dr[5].ToString();
                        listAppointment.Add(appointment);
                    }
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _command.Connection.Close();
            }
            return(listAppointment);
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "Id,DoctorId,PatientId,Location,Date,Time")] ApointmentFixed apointmentFixed, int?dd, int p, int d)
        {
            if (ModelState.IsValid)
            {
                apointmentFixed.DoctorId  = d;
                apointmentFixed.PatientId = p;
                db.ApointmentFixeds.Add(apointmentFixed);
                db.SaveChanges();

                Apointment apointment = db.Apointments.Find(dd);
                db.Apointments.Remove(apointment);
                db.SaveChanges();
                //return RedirectToAction("Index");


                return(RedirectToAction("Index"));
            }
            return(View(apointmentFixed));
        }
コード例 #11
0
        public async Task <IActionResult> leaveApointment(int id)
        {
            Apointment apointment = null;

            try
            {
                using (var unitOfWork = new UnitOfWork(new ModelContext()))
                {
                    apointment         = unitOfWork.Apointment.Get(id);
                    apointment.Taken   = false;
                    apointment.Patient = null;
                    unitOfWork.Apointment.Update(apointment);
                    unitOfWork.Complete();
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }

            return(Ok(apointment));
        }
コード例 #12
0
        public async Task <IHttpActionResult> Update(long id, [FromBody] Apointment entity)
        {
            var query = from a in DataContext.Apointment
                        where a.Id == id
                        select a;
            var error = "";
            var data  = query.FirstOrDefault();

            if (data == null)
            {
                error = $"data {id} not found";
            }
            else
            {
                Utils.CopyProperties(entity, data, ID_EXCEPTION);
                DataContext.Entry(data).State = System.Data.Entity.EntityState.Modified;
                await DataContext.SaveChangesAsync();
            }
            return(Json(new ResponseData <Apointment>()
            {
                Message = error
            }));
        }
コード例 #13
0
        public async Task <IActionResult> takeApointment(int id)
        {
            Apointment apointment = null;
            User       user       = GetCurrentUser();

            try
            {
                using (var unitOfWork = new UnitOfWork(new ModelContext()))
                {
                    apointment         = unitOfWork.Apointment.Get(id);
                    apointment.Patient = unitOfWork.Users.Get(user.Id);
                    apointment.Taken   = true;
                    unitOfWork.Apointment.Update(apointment);
                    unitOfWork.Complete();
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }

            return(Ok(apointment));
        }
コード例 #14
0
        public async Task <IActionResult> CreateApointment(Apointment input)
        {
            Apointment apointment = null;

            apointment      = new Apointment();
            apointment.Date = input.Date;

            try
            {
                using (var unitOfWork = new UnitOfWork(new ModelContext()))
                {
                    apointment.Doctor = unitOfWork.Users.Get(input.Doctor.Id);

                    unitOfWork.Apointment.Add(apointment);
                    unitOfWork.Complete();
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
            return(Ok(apointment));
        }
コード例 #15
0
        // GET: Apointment/Delete/5
        public ActionResult Delete(int?id, int?p)
        {
            if (Session["Palogin"].ToString() == "")
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (((Models.Patient)Session["Pa"]).Id != p)
            {
                Session["Msg"] = "You Have No Information";
                return(RedirectToAction("Index"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Apointment apointment = db.Apointments.Find(id);

            if (apointment == null)
            {
                return(HttpNotFound());
            }
            return(View(apointment));
        }
コード例 #16
0
 public AppointmentsController(Apointment appointment)
 {
     this._appointment = appointment;
 }
コード例 #17
0
        public bool InsertAppoinment(Apointment obj)
        {
            bool result = _appoinmentDataMapper.InsertAppointment(obj);

            return(result);
        }