public ActionResult PatientAppointment(int?patient_id, int?appointment_id) { ViewBag.ListDoctor = new DoctorsDAL().ListOfRecords().Where(x => x.EmployeeTypeID == 1).ToList(); var model = new tblPatientAppointment(); model.patient_id = Convert.ToInt32(patient_id); if (patient_id != null && appointment_id != null) { model = new PatientDAL().GetPatientAppointment(Convert.ToInt32(patient_id), Convert.ToInt32(appointment_id)); } return(View(model)); }
public ActionResult PatientAppointment(tblPatientAppointment obj, int?appointment_id) { string p_id = Request.Form["hdnPatientId"]; string hdndate = Request.Form["hdndate"]; string[] date = hdndate.Split('-'); hdndate = date[0]; try { string username = ""; HttpCookie cookie = HttpContext.Request.Cookies["AdminCookies"]; if (cookie != null) { username = Convert.ToString(cookie.Values["UserName"]); } obj.CreatedAt = DateTime.UtcNow; obj.CreatedBy = username; obj.isActive = true; obj.patient_id = Convert.ToInt32(p_id); string time = Convert.ToDateTime(date[1]).ToLongTimeString(); date = time.Split(' '); obj.AppointmentDate = hdndate + time; // TODO: Add insert logic here if (appointment_id != null && appointment_id != 0) { obj.ID = Convert.ToInt32(appointment_id); new PatientDAL().UpdatePatientAppointment(obj); appointment_id = obj.ID; TempData["AlertTask"] = "Patient updated successfully"; } else { new PatientDAL().SavePatientAppointment(obj); appointment_id = obj.ID; TempData["AlertTask"] = "Patient Admit added successfully"; } return(Redirect("/patient-appointments?patient_id=" + obj.patient_id)); // return Redirect("patient-admission?appointment_id=" + appointment_id+ "&patient_id=" + p_id); } catch (Exception ex) { string error = ex.ToString(); return(View()); } }