public ActionResult Create(FormCollection collection)//[Bind(Include = "Id,IdP,FName,LName,gender,DateOfBirth,DateOfRegistration,email,PhoneNumber")] PatientViewModel patientViewModel) { try { PatientAdminLogic bl = new PatientAdminLogic(); bl.addPatient(collection["FName"], collection["LName"], collection["email"], Convert.ToInt64(collection["IdP"]), Convert.ToInt64(collection["PhonNumber"]), Convert.ToDateTime(collection["DateOfBirthd"]), DateTime.Now, collection["gender"]); ViewBag.Message = String.Format("The patient was added successfully."); return(View("Home")); } catch (Exception ex) { if (ex.Message == "not correct date") { ViewBag.Message = String.Format("One of the details were not correct, try again"); } if (ex.Message == "The ID number already exists in the system") { ViewBag.Message = String.Format("The ID number already exists in the system, try again"); } return(View()); } }
public ActionResult DeleteConfirmed(int id) { PatientAdminLogic bl = new PatientAdminLogic(); bl.deletePatient(id); ViewBag.Message = String.Format("The patient was deleted successfully."); return(View("Home")); }
public static MvcHtmlString DropDownListForPatient(this HtmlHelper htmlHelper, string name) { PatientAdminLogic bl = new PatientAdminLogic(); string options = ""; foreach (var user in bl.listPatient()) { options += $"<option value ='{user.IdP}'> {user.IdP} </option>"; } return(new MvcHtmlString($"<select name={name} style='color:black style:position:relative; width:220px;'>{options}</select>")); }
public ActionResult Edit(FormCollection collection) //[Bind(Include = "Id,IdP,FName,LName,gender,DateOfBirth,DateOfRegistration,email,PhoneNumber")] PatientViewModel patientViewModel) { try { PatientAdminLogic bl = new PatientAdminLogic(); bl.EditPatient(collection["FName"], collection["LName"], collection["email"], Convert.ToInt64(collection["IdP"]), Convert.ToInt64(collection["PhonNumber"]), Convert.ToDateTime(collection["DateOfBirthd"]), Convert.ToDateTime(collection["DateOfRegistration"]), collection["gender"]); ViewBag.Message = String.Format("The patient was edited successfully."); return(View("Home")); } catch { return(View()); } }