public ActionResult EditComplaint([ModelBinder(typeof(VMComplaintCustomBinder))] ComplaintInfoViewModel civm, List <String> date_informed_the_hf, List <String> date_hf_submitted_reply, List <String> date_release_to_records, List <String> date_final_resolution, List <String> complaint_type, List <String> complaint_assistance, List <String> actionTaken, List <String> actionDate, List <String> remarks) { Int32 complaintID = Convert.ToInt32(Session["EditComplaintID"].ToString()); try { civm.complaint_type = complaint_type; civm.assistanceNeeded = complaint_assistance; civm.date_informed_the_hf = date_informed_the_hf; civm.date_hf_submitted_reply = date_hf_submitted_reply; civm.date_release_to_records = date_release_to_records; civm.date_final_resolution = date_final_resolution; civm.actionTaken = actionTaken; civm.actionDate = actionDate; civm.remarks = remarks; //UPDATE THE COMPLAINT this.cr.Edit(civm._complaints); this.nameOfComplainantRepo.Edit(civm._nameOfComplainant); this._patientRepo.Edit(civm._complaintPatient); SaveComplaint(civm, complaintID); TempData["EditSuccess"] = true; } catch { TempData["EditSuccess"] = false; } return(RedirectToAction("EditComplaint", new { ID = complaintID.ToString() })); }
public ActionResult CreateComplaint([ModelBinder(typeof(VMComplaintCustomBinder))] ComplaintInfoViewModel civm, List <String> date_informed_the_hf, List <String> date_hf_submitted_reply, List <String> date_release_to_records, List <String> date_final_resolution, List <String> complaint_type, List <String> complaint_assistance, List <String> actionTaken, List <String> actionDate, List <String> remarks) { civm.complaint_type = complaint_type; civm.assistanceNeeded = complaint_assistance; civm.date_informed_the_hf = date_informed_the_hf; civm.date_hf_submitted_reply = date_hf_submitted_reply; civm.date_release_to_records = date_release_to_records; civm.date_final_resolution = date_final_resolution; civm.actionTaken = actionTaken; civm.actionDate = actionDate; civm.remarks = remarks; //ADD NEW COMPLAINT TO DATABASE AND RETURN ITS ID(PRIMARY KEY) AFTER INSERTED Int32 complaintID = this.cr.Add(civm._complaints); civm._nameOfComplainant.complaintId = complaintID; this.nameOfComplainantRepo.Add(civm._nameOfComplainant); civm._complaintPatient.complaintID = complaintID; this._patientRepo.Add(civm._complaintPatient); SaveComplaint(civm, complaintID); return(RedirectToAction("Complaints")); }
public void SaveComplaint(ComplaintInfoViewModel civm, Int32 complaintID) { this.cr.RemoveComplaintTypeByComplaintID(complaintID, "C"); this.cr.RemoveComplaintTypeByComplaintID(complaintID, "A"); this.cr.RemoveComplaintsDates(complaintID, "date_informed_the_hf"); this.cr.RemoveComplaintsDates(complaintID, "date_hf_submitted_reply"); this.cr.RemoveComplaintsDates(complaintID, "date_release_to_records"); this.cr.RemoveComplaintsDates(complaintID, "date_final_resolution"); this.cr.RemoveComplaintActions(complaintID); this.cr.RemoveComplaintRemarks(complaintID); if (civm.remarks != null) { foreach (String remark in civm.remarks) { this.cr.InsertComplaintRemarks(new remarks { remark = remark, complaintID = complaintID }); } } if (civm.complaint_type != null) { foreach (String complaintTypeID in civm.complaint_type) { this.cr.InsertComplaintTypeAssistance( new complaint_types_list { ComplaintID = complaintID, ComplaintTypeId = Int32.Parse(complaintTypeID), Member = "C" }); } } if (civm.assistanceNeeded != null) { foreach (String complaintTypeID in civm.assistanceNeeded) { this.cr.InsertComplaintTypeAssistance( new complaint_types_list { ComplaintID = complaintID, ComplaintTypeId = Int32.Parse(complaintTypeID), Member = "A" }); } } if (civm.date_informed_the_hf != null) { foreach (String s in civm.date_informed_the_hf) { this.cr.InsertComplaintsDates(new complaint_dates { Date = s, complaintID = complaintID, member = "date_informed_the_hf" }); } } if (civm.date_hf_submitted_reply != null) { foreach (String s in civm.date_hf_submitted_reply) { this.cr.InsertComplaintsDates(new complaint_dates { Date = s, complaintID = complaintID, member = "date_hf_submitted_reply" }); } } if (civm.date_release_to_records != null) { foreach (String s in civm.date_release_to_records) { this.cr.InsertComplaintsDates(new complaint_dates { Date = s, complaintID = complaintID, member = "date_release_to_records" }); } } if (civm.date_final_resolution != null) { foreach (String s in civm.date_final_resolution) { this.cr.InsertComplaintsDates(new complaint_dates { Date = s, complaintID = complaintID, member = "date_final_resolution" }); } } if (civm.actionTaken != null) { for (int i = 0; i < civm.actionTaken.Count(); i++) { this.cr.InsertComplaintActions(new complaint_action_dates { Date = Convert.ToDateTime(civm.actionDate[i]), Action = civm.actionTaken[i], complaintID = complaintID }); } } }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var form = controllerContext.HttpContext.Request.Form; ComplaintInfoViewModel _civm = new ComplaintInfoViewModel(); if (HttpContext.Current.Session["EditComplaintID"] != null) { Int32 complaintID = Convert.ToInt32(HttpContext.Current.Session["EditComplaintID"].ToString()); _civm._complaints = this.cr.FindById(complaintID); _civm._nameOfComplainant = this.nameOfComplainantRepo.FindById(complaintID); _civm._complaintPatient = this._patientRepo.FindById(complaintID); } else { _civm._complaints = new complaints(); _civm._complaints.date_created = DateTime.Now; _civm._complaints.staff = HttpContext.Current.User.Identity.GetUserName(); _civm._complaints.active = true; _civm._nameOfComplainant = new complaint_nameOfComplainant(); _civm._complaintPatient = new complaint_patient(); } //COMPLAINT INFORMATION if (form.Get("anonymous") != null && form.Get("anonymous").Trim().ToLower() == "1") { _civm._complaints.annonymos = true; } else { _civm._complaints.annonymos = false; } if (form.Get("pccCheck") != null && form.Get("pccCheck").Trim().ToLower() == "1") { _civm._complaints.pccCheck = true; _civm._complaints.pccNumber = form.Get("pccNumber"); } else { _civm._complaints.pccCheck = false; _civm._complaints.communication_form = Convert.ToInt32(form.Get("communication_form")); } _civm._complaints.codeNumber = form.Get("codeNumber"); try { _civm._complaints.hospitalID = Convert.ToInt32(form.Get("hospitalID")); } catch { } _civm._complaints.reasonOfConfinement = form.Get("reasonOfConfinement"); _civm._complaints.other_complaint = form.Get("other_complaint"); _civm._complaints.assistance_needed = form.Get("other_assistance"); _civm._complaints.ownership = form.Get("ownership"); try { _civm._complaints.dateReceive = Convert.ToDateTime(form.Get("date_receive")); } catch { _civm._complaints.dateReceive = DateTime.Now; } _civm._complaints.status = Convert.ToInt32(form.Get("status")); //COMPLAINANT INFORMATION _civm._nameOfComplainant.firstname = form.Get("firstname"); _civm._nameOfComplainant.email = form.Get("email"); _civm._nameOfComplainant.lastname = form.Get("lastname"); _civm._nameOfComplainant.mi = form.Get("mi"); _civm._nameOfComplainant.civil_status = form.Get("civil_status"); _civm._nameOfComplainant.gender = form.Get("gender"); _civm._nameOfComplainant.relationship = form.Get("relationship"); _civm._nameOfComplainant.telNo = form.Get("telNo"); _civm._nameOfComplainant.mobile = form.Get("mobile"); _civm._nameOfComplainant.address = form.Get("address"); //COMPLAINT PATIENT INFORMATION _civm._complaintPatient.p_firstname = form.Get("p_firstname"); _civm._complaintPatient.p_lastname = form.Get("p_lastname"); _civm._complaintPatient.p_mi = form.Get("p_mi"); _civm._complaintPatient.date_confined = form.Get("date_confined"); try { _civm._complaintPatient.age = Convert.ToInt32(form.Get("age")); } catch { } return(_civm); }