public ActionResult Create([Bind(Include = "Id,Date,PatientName,DateOfBirth,Address,HomeTelephone,CellPhone,IdentityNo,Employer,WorkNumber,EmergencyContact,NextOfKin,HomePhone,InsuranceName,PolicyNumber,InsuranceNumber,GenderId")] PatientRecord patientRecord)
        {
            if (ModelState.IsValid)
            {
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    //Check if patients Id number is unique
                    var exist = db.PatientRecords.Where(i => i.IdentityNo == patientRecord.IdentityNo);
                    if (exist.Count() == 0)
                    {
                        patientRecord.Date = patientRecord.StartDate();
                        db.PatientRecords.Add(patientRecord);
                        db.SaveChanges();

                        TempData["SM"] = "Successfully Registerd!";
                        return(RedirectToAction("Index"));    /*Redirect to create patients default login details*/
                    }
                    else
                    {
                        TempData["UM"] = "Patient Already Exists. Check List of Patients!";
                        return(RedirectToAction("Index"));
                    }
                }
            }

            ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "_Gender", patientRecord.GenderId);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(PatientRecord patient)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //Check for patient existance
                    var exist = interfaceobj.GetModel().Where(i => i.IdentityNo == patient.IdentityNo);

                    //If Patient doesn't exist
                    if (exist.Count() == 0)
                    {
                        patient.Date = patient.StartDate();
                        interfaceobj.InsertModel(patient);
                        interfaceobj.Save();

                        TempData["SM"] = "Successfully Registerd!";

                        //Redirect to create patients login details
                        return(RedirectToAction("SignUp", "Register"));
                    }
                    else
                    {
                        //If patients record exist
                        TempData["UM"] = "Patient Id No. Already Exists. Check List of Patients!";
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try Again and if the problem persists see your system administrator.");
            }
            TempData["UM"] = "Unable to save. Try Again and if the problem persists see your system administrator!";


            ViewBag.GenderId = new SelectList(db.genders, "GenderId", "_Gender", patient.GenderId);
            return(RedirectToAction("Index"));
        }