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(); } }
// 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)); }
// 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")); }
public ActionResult DeleteConfirmed(int id) { Apointment apointment = db.Apointments.Find(id); db.Apointments.Remove(apointment); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> Add([FromBody] Apointment entity) { DataContext.Apointment.Add(entity); await DataContext.SaveChangesAsync(); return(Json(new ResponseData <Apointment>() { Data = entity })); }
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)); }
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)); }
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()); }
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); }
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)); }
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)); }
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 })); }
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)); }
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)); }
// 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)); }
public AppointmentsController(Apointment appointment) { this._appointment = appointment; }
public bool InsertAppoinment(Apointment obj) { bool result = _appoinmentDataMapper.InsertAppointment(obj); return(result); }