Example #1
0
        public ActionResult PostPatientData(PatientViewModel model)
        {
            int mid = Convert.ToInt32(Session["MemberId"]);

            using (ProjectEntities db = new ProjectEntities())
            {
                var getdata = db.Patients.FirstOrDefault(a => a.MemberId == mid);
                if (getdata == null)
                {
                    // insert
                    db.InsertPatient(model.FirstName, model.LastName, model.DateOfBirth,
                                     model.Gender, model.Address, mid);

                    ViewBag.Message = "Inserted";
                }
                else
                {
                    // update
                    db.UpdatePatient(mid, model.FirstName, model.LastName, model.DateOfBirth,
                                     model.Gender, model.Address);

                    ViewBag.Message = "Updated";
                }
            }
            return(View("EditProfile"));
        }