public ActionResult Edit(AppointmentDetail appointmentDetail) { if (Session["UserEmail"] != null && Session["UserRole"].ToString() == "Doctor") { if (ModelState.IsValid) { AppointmentDetail objAppointmentDetails = db.AppointmentDetails.Where(x => x.AppointmentId == appointmentDetail.AppointmentId).FirstOrDefault(); objAppointmentDetails.PatientId = appointmentDetail.PatientId; objAppointmentDetails.Age = appointmentDetail.Age; objAppointmentDetails.DiseaseInfo = appointmentDetail.DiseaseInfo; objAppointmentDetails.AppointmentDate = appointmentDetail.AppointmentDate; objAppointmentDetails.AppointmentTime = appointmentDetail.AppointmentTime; objAppointmentDetails.SheduleUpdated = true; objAppointmentDetails.SheduleDate = DateTime.Now; //db.Entry(appointmentDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.PatientId = new SelectList(db.PatientDetails, "Patient_Id", "Name", appointmentDetail.PatientId); return(View(appointmentDetail)); } Response.Write("<script>alert('Please Login')</script>"); FormsAuthentication.SignOut(); Session.Clear(); return(RedirectToAction("SignIn", "Auth")); }
public void AddAppointmentDetail(BookingViewModel booking, long appointmentId) { DateTime startTime = booking.DatetimeBooked; DateTime endTime; for (int i = 0; i < booking.Services.Count; i++) { var bedId = _context.Beds.Where(p => p.Status == 0).Select(p => p.Id).FirstOrDefault(); int time = _context.Services.Where(p => p.Id == booking.Services[i]).Select(p => p.Time).First(); endTime = startTime.AddMinutes(time); AppointmentDetail detail = new AppointmentDetail { AppointmentId = appointmentId, ServiceId = booking.Services[i], Order = i + 1, StartTime = startTime, FinishTime = endTime, BedId = bedId }; detail.AddEntity(); var result = _context.AppointmentDetails.AddAsync(detail).Result; startTime = endTime; } _context.SaveChanges(); //return "Succeed"; }
public async Task <IActionResult> PutAppointmentDetail(int id, AppointmentDetail appointmentDetail) { if (id != appointmentDetail.AppointmentId) { return(BadRequest()); } _context.Entry(appointmentDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppointmentDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <AppointmentDetail> > PostAppointmentDetail(AppointmentDetail appointmentDetail) { _context.AppointmentDetails.Add(appointmentDetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAppointmentDetail", new { id = appointmentDetail.AppointmentId }, appointmentDetail)); }
public async Task <IActionResult> Create(int?appointmentId, [Bind("AppointmentDetailId,AppointmentId,ProductId,ProcedureMinutes,RetailPrice,Quantity,Discount,Total,Comments")] AppointmentDetail appointmentDetail) { TempData["id"] = ViewBag.id; if (TempData["id"] != null) { appointmentDetail.AppointmentId = Convert.ToInt32(TempData["id"]); } try { if (ModelState.IsValid) { _context.Add(appointmentDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AppointmentId"] = new SelectList(_context.Appointment, "AppointmentId", "AppointmentId", appointmentDetail.AppointmentId); ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", appointmentDetail.ProductId); return(View(appointmentDetail)); } catch (Exception ex) { //write this down TempData["Message"] = ex.InnerException.Message; //write this down return(View(appointmentDetail)); } }
public async Task <IActionResult> Edit(int id, [Bind("AppointmentDetailId,AppointmentId,ProductId,ProcedureMinutes,RetailPrice,Quantity,Discount,Total,Comments")] AppointmentDetail appointmentDetail) { if (id != appointmentDetail.AppointmentDetailId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(appointmentDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppointmentDetailExists(appointmentDetail.AppointmentDetailId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AppointmentId"] = new SelectList(_context.Appointment, "AppointmentId", "AppointmentId", appointmentDetail.AppointmentId); ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", appointmentDetail.ProductId); return(View(appointmentDetail)); }
public void DuplicateAppointmentDetailForSameAppointmentThrowsException() { var appointmentWithDetail = new Appointment { AppointmentTime = DateTime.Now, AppointmentName = "AppointmentWithDetail" }; var appointmentDetail = new AppointmentDetail { Appointment = appointmentWithDetail, Organiser = "organiser", Attendees = new List <string> { "attendee1", "attendee2" } }; var appointmentDetail2 = new AppointmentDetail { Appointment = appointmentWithDetail, Organiser = "organiser2", Attendees = new List <string> { "attendee3", "attendee4" } }; var provider = _appointmentProviderStrategy.GetAppointmentRepository(); _testContext.Appointments.Add(appointmentWithDetail); _testContext.AppointmentDetails.Add(appointmentDetail); _testContext.AppointmentDetails.Add(appointmentDetail2); provider.GetAppointmentDetails(appointmentDetail.Appointment.Id); }
public ActionResult DeleteConfirmed(int id) { AppointmentDetail appointmentDetail = db.AppointmentDetails.Find(id); db.AppointmentDetails.Remove(appointmentDetail); db.SaveChanges(); return RedirectToAction("Index"); }
public static AppointmentDetail GetAppointmentDetailById(int Id) { var res = new AppointmentDetail(); res.Id = Id; res.Appointment = AllAppointments.FirstOrDefault(x => x.Id == Id); res.Organizer = new Person() { Name = "Name of " + Id.ToString(), Surname = "Surname of " + Id.ToString() }; res.Attendees = new List <Attendee>(); res.Attendees.Add(new Attendee() { Name = "TestName1", Surname = "TestSurname1" }); res.Attendees.Add(new Attendee() { Name = "TestName2", Surname = "TestSurname2" }); res.Attendees.Add(new Attendee() { Name = "TestName3", Surname = "TestSurname3" }); return(res); }
public void UpdateExistentAppointment() { var appointment = new Appointment { AppointmentName = "appointment", AppointmentTime = DateTime.Now }; var appointmentDetail = new AppointmentDetail { Appointment = appointment, Organiser = "testOrganiser", Attendees = new List <string> { "attendee1", "attendee2" } }; _repository.AddAppointment(appointmentDetail); appointment.AppointmentName = "updatedAppointment"; var updateResponse = _repository.UpdateApointment(appointment); var updatedAppointment = _repository.GetAppointmentById(appointment.Id); Assert.IsTrue(updatedAppointment.AppointmentName == "updatedAppointment"); }
public void saveAppointment() { int Appointment_id = Int32.Parse(txtappointmentid.Text); String Dentist_id = txtdentistid.Text; String Patient_id = txtpatientid.Text; String Room_id = txtroomid.Text; String Appointment_start_time = txtappointmentstarttime.Text; String Appointment_end_time = txtappointmentendtime.Text; String Modified_by = txtmodifiedby.Text; AppointmentDetail a = new AppointmentDetail(); a.Appointment_id1 = Appointment_id; a.Dentist_id1 = Dentist_id; a.Patient_id1 = Patient_id; a.Room_id1 = Room_id; a.Appointment_start_time1 = Appointment_start_time; a.Appointment_end_time1 = Appointment_end_time; a.Modified_by = Modified_by; // dentistList.Add(a); a.insertAppointment(); bindGrid(); }
public void bindGrid() { AppointmentDetail a = new AppointmentDetail(); DataSet ds = a.getAppointmentData(); gvAppointment.DataSource = ds; gvAppointment.DataBind(); }
public bool createAppointment(AppointmentDetail a) { using (AppointmentSchedulerEntities3 conf = new AppointmentSchedulerEntities3()) { a.AppointmentID = Guid.NewGuid().ToString(); conf.AppointmentDetails.Add(a); conf.SaveChanges(); } return(true); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public PartialViewResult GetAppointmentDetail(Guid id) { var appointment = _provider.GetAppointmentDetails(id); var detail = new AppointmentDetail { Organiser = appointment.Organiser, Attendees = appointment.Attendees }; return(PartialView("Details", detail)); }
public ActionResult Edit([Bind(Include = "appointmentDetailID,qtyProcedure,price,AppointmentID,procedureId")] AppointmentDetail appointmentDetail) { if (ModelState.IsValid) { db.Entry(appointmentDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AppointmentID = new SelectList(db.Appointments, "appointmentID", "description", appointmentDetail.AppointmentID); ViewBag.procedureId = new SelectList(db.Procedures, "procedureID", "description", appointmentDetail.procedureId); return(View(appointmentDetail)); }
public ActionResult Edit([Bind(Include = "AppointmentdetailID,cost,appointmentID,vetID")] AppointmentDetail appointmentDetail) { if (ModelState.IsValid) { db.Entry(appointmentDetail).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.appointmentID = new SelectList(db.Appointments, "AppointmentID", "description", appointmentDetail.appointmentID); ViewBag.vetID = new SelectList(db.vets, "VetID", "firstName", appointmentDetail.vetID); return View(appointmentDetail); }
public ActionResult Edit([Bind(Include = "appointmentDetailId,price,doctorId,appointmentId")] AppointmentDetail appointmentDetail) { if (ModelState.IsValid) { db.Entry(appointmentDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.appointmentId = new SelectList(db.Appointments, "appointmentId", "description", appointmentDetail.appointmentId); ViewBag.doctorId = new SelectList(db.Doctors, "doctorId", "doctorfirstName", appointmentDetail.doctorId); return(View(appointmentDetail)); }
public ActionResult Edit([Bind(Include = "appointmentDetailID,prescriptionQuantityOrdered,price,appointmentID,patientID")] AppointmentDetail appointmentDetail) { if (ModelState.IsValid) { db.Entry(appointmentDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.appointmentID = new SelectList(db.Appointments, "appointmentID", "description", appointmentDetail.appointmentID); ViewBag.patientID = new SelectList(db.Patients, "patientID", "description", appointmentDetail.patientID); return(View(appointmentDetail)); }
public ActionResult BookAppointment(string id) { AppointmentDetail a = new AppointmentDetail(); a.DoctorID = id; a.PatientID = this.HttpContext.Session["patientname"].ToString(); a.StartTime = DateTime.Now; a.EndTime = DateTime.Now.AddMinutes(30); m.createAppointment(a); // return "Appointment created successfully"; return(View("ListAppointments", m.GetAllAppointments())); }
// GET: AppointmentDetails/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } AppointmentDetail appointmentDetail = db.AppointmentDetails.Find(id); if (appointmentDetail == null) { return HttpNotFound(); } return View(appointmentDetail); }
public List <AppointmentDetail> GetNextMessagesAppointmentDetailById(int id) { List <AppointmentDetail> sentmessageAppointmentList = new List <AppointmentDetail>(); var currentDate = System.DateTime.Now; sentmessageAppointmentList = (from appoint in _context.Appointments.Where(c => c.Appointment_PatientID == id) join sch in _context.ScheduleMessages on appoint.Appointment_Trigger_EventId equals sch.ScheduleMessage_TriggerEventID join evt in _context.TriggerEvents on appoint.Appointment_Trigger_EventId equals evt.TriggerEvent_ID join user in _context.Users on appoint.Appointment_PatientID equals user.User_ID select new AppointmentDetail { MessageID = sch.ScheduleMessage_ID, Message = sch.ScheduleMessage_Message, AppointmentDate = appoint.Appointment_StartTime, TriggerEventId = sch.ScheduleMessage_TriggerEventID, Time = sch.ScheduleMessage_Time, AppoinmentScheduleDay = sch.Appointment_Schedule, User_ID = user.User_ID, }).ToList(); // sentmessageAppointmentList = sentmessageAppointmentList.Where(m => m.AppointmentDate.Value.AddDays(-1).Date == currentDate.Date || m.AppointmentDate.Value.AddDays(-7).Date == currentDate.Date).ToList(); sentmessageAppointmentList = sentmessageAppointmentList.Where(m => m.AppointmentDate.Value > currentDate.AddDays(-10)).ToList(); var appointResult = sentmessageAppointmentList.GroupBy(c => new { c.MessageID }) .Select(s => s.First()); var newAppoinmentList = new List <AppointmentDetail>(); foreach (var item in appointResult) { AppointmentDetail app = new AppointmentDetail(); app.MessageID = item.MessageID; app.Message = item.Message; app.User_ID = item.User_ID; app.TriggerEventId = item.TriggerEventId; if (item.AppoinmentScheduleDay != null) { var finalAppoinmentDate = item.AppointmentDate.Value.AddDays(item.AppoinmentScheduleDay.Value); app.AppoinmentMessageDeliveryDateTime = finalAppoinmentDate.ToShortDateString() + " " + item.Time; } newAppoinmentList.Add(app); } // var finalAppoinmentDate = item.AppointmentDate.Value.AddDays(item.Day.Value); return(newAppoinmentList.ToList()); // return appointResult.ToList(); }
// GET: AppointmentDetails/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } AppointmentDetail appointmentDetail = db.AppointmentDetails.Find(id); if (appointmentDetail == null) { return HttpNotFound(); } ViewBag.appointmentID = new SelectList(db.Appointments, "AppointmentID", "description", appointmentDetail.appointmentID); ViewBag.vetID = new SelectList(db.vets, "VetID", "firstName", appointmentDetail.vetID); return View(appointmentDetail); }
// GET: AppointmentDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AppointmentDetail appointmentDetail = db.AppointmentDetails.Find(id); if (appointmentDetail == null) { return(HttpNotFound()); } ViewBag.appointmentId = new SelectList(db.Appointments, "appointmentId", "description", appointmentDetail.appointmentId); ViewBag.doctorId = new SelectList(db.Doctors, "doctorId", "doctorfirstName", appointmentDetail.doctorId); return(View(appointmentDetail)); }
// GET: AppointmentDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AppointmentDetail appointmentDetail = db.AppointmentDetails.Find(id); if (appointmentDetail == null) { return(HttpNotFound()); } ViewBag.appointmentID = new SelectList(db.Appointments, "appointmentID", "description", appointmentDetail.appointmentID); ViewBag.patientID = new SelectList(db.Patients, "patientID", "description", appointmentDetail.patientID); return(View(appointmentDetail)); }
public void Add2AppointmentsAndThenGetOneInFebruary() { int month = 2; var repository = _appointmentProviderStrategy.GetAppointmentRepository(AppointmentSelector.Monthly); var appointment1 = new Appointment { AppointmentName = "test", AppointmentTime = new DateTime(2017, month, 1), }; var appointmentDetail1 = new AppointmentDetail { Appointment = appointment1, Organiser = "testo", Attendees = new List <string> { "test1", "test2" } }; repository.AddAppointment(appointmentDetail1); var appointment2 = new Appointment { AppointmentName = "test2", AppointmentTime = DateTime.Now, }; var appointmentDetail2 = new AppointmentDetail { Appointment = appointment2, Organiser = "testo", Attendees = new List <string> { "test1", "test2" } }; repository.AddAppointment(appointmentDetail2); var savedAppointment = repository.GetAppointments(month).First(); Assert.AreEqual(appointment1, savedAppointment); }
public ActionResult Create(TreatmentNoteCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTreatmentNoteService(); if (service.CreateTreatmentNote(model)) { var userId = Guid.Parse(User.Identity.GetUserId()); var aptservice = new AppointmentService(userId); AppointmentDetail appointment = aptservice.GetAppointmentById(model.AppointmentId); TempData["SaveResult"] = "Your note was saved."; return(RedirectToAction("Index", "TreatmentNote", new { id = appointment.PatientId })); } ModelState.AddModelError("", "Note could not be created."); return(View(model)); }
public async Task <IActionResult> Create([Bind("AppointmentDetailId,AppointmentId,ProductId,ProcedureMinutes,RetailPrice,Quantity,Discount,Total,Comments")] AppointmentDetail appointmentDetail) { try { if (ModelState.IsValid) { _context.Add(appointmentDetail); await _context.SaveChangesAsync(); TempData["message"] = "Appointment Created"; return(RedirectToAction(nameof(Index))); } } catch (Exception ex) { TempData["message"] = "Create Failed" + ex.GetBaseException().Message; } ViewData["AppointmentId"] = new SelectList(_context.Appointment, "AppointmentId", "AppointmentId", appointmentDetail.AppointmentId); ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", appointmentDetail.ProductId); return(View(appointmentDetail)); }
// GET: DoctorAppointment/Edit/5 /// <summary>Edits the specified identifier.</summary> /// <param name="id">The identifier.</param> /// <returns></returns> public ActionResult Edit(int?id) { if (Session["UserEmail"] != null && Session["UserRole"].ToString() == "Doctor") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AppointmentDetail appointmentDetail = db.AppointmentDetails.Find(id); if (appointmentDetail == null) { return(HttpNotFound()); } ViewBag.PatientId = new SelectList(db.PatientDetails, "Patient_Id", "Name", appointmentDetail.PatientId); return(View(appointmentDetail)); } Response.Write("<script>alert('Please Login')</script>"); FormsAuthentication.SignOut(); Session.Clear(); return(RedirectToAction("SignIn", "Auth")); }
public ActionResult Create(AppointmentDetail appointmentDetail) { if (Session["UserEmail"] != null && Session["UserRole"].ToString() == "Doctor") { if (ModelState.IsValid) { appointmentDetail.SheduleUpdated = false; appointmentDetail.SheduleDate = DateTime.Now; db.AppointmentDetails.Add(appointmentDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PatientId = new SelectList(db.PatientDetails, "Patient_Id", "Name", appointmentDetail.PatientId); return(View(appointmentDetail)); } Response.Write("<script>alert('Please Login')</script>"); FormsAuthentication.SignOut(); Session.Clear(); return(RedirectToAction("SignIn", "Auth")); }
public async Task <IActionResult> Create(int apptid, [Bind("AppointmentDetailId,AppointmentId,ProductId,ProcedureMinutes,RetailPrice,Quantity,Discount,Total,Comments")] AppointmentDetail appointmentDetail) { //Check for null before converting to int if (TempData["AppointmentId"] != null) { appointmentDetail.AppointmentId = Convert.ToInt32(TempData["AppointmentId"]); } //appointmentDetail.AppointmentId = apptid; //throws FK error?? //Set defaults to zero as these are required attributes appointmentDetail.RetailPrice = 0; appointmentDetail.ProcedureMinutes = 0; appointmentDetail.Total = 0; try { if (ModelState.IsValid) { _context.Add(appointmentDetail); await _context.SaveChangesAsync(); TempData["message"] = "Saved to DB"; return(RedirectToAction(nameof(Index))); } } catch (Exception ex) { TempData["message"] = ex.InnerException.Message; } ViewData["AppointmentId"] = new SelectList(_context.Appointment, "AppointmentId", "AppointmentId", appointmentDetail.AppointmentId); ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", appointmentDetail.ProductId); TempData["message"] = "Model Validation dint pass"; return(View(appointmentDetail)); }