//insert patient into db
 public bool commitInsert(patient pat)
 {
     using (objLinq)
     {
         objLinq.patients.InsertOnSubmit(pat);
         objLinq.SubmitChanges();
         return true;
     }
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the patient as a user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);
                    //Add a role to the new user
                    Roles.AddUserToRole(model.UserName, "patient");

                    //Create a patient object from user input

                    patient objPatient = new patient();
                    objPatient.user_name = model.UserName;
                    objPatient.health_card = model.health_card;
                    objPatient.first_name = model.first_name;
                    objPatient.last_name = model.last_name;
                    objPatient.birth_date = Convert.ToDateTime(model.bith_date);
                    objPatient.gender = model.gender;
                    objPatient.email = model.email;
                    objPatient.phone = model.phone;
                    objPatient.address = model.address;
                    objPatient.postal_code = model.postal_code;
                    objPatient.city = model.city;
                    objPatient.province = model.province;

                    //Insert patient into database patient table using patientClass
                    PatientClass objPat = new PatientClass();
                    objPat.commitInsert(objPatient);

                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 partial void Deletepatient(patient instance);
 partial void Updatepatient(patient instance);
 partial void Insertpatient(patient instance);
 public ActionResult PatientDelete(int id, patient pat)
 {
     var UserName = pat.user_name;
     try
     {
         objPat.commitDelete(id);
         Roles.RemoveUserFromRole(UserName, "patient");
         Membership.DeleteUser(UserName);
         return RedirectToAction("ListPatient");
     }
     catch
     {
         return View();
     }
 }