public ActionResult PostEditPateint(PateintViewModel model) { if (!ModelState.IsValid) { return(View("EditPateint")); } using (ProjectEntities1 db = new ProjectEntities1()) { int memid = Convert.ToInt32(Session["MemberId"]); var gdata = db.Patients.FirstOrDefault(a => a.MemberId == memid); MemberModel m = new MemberModel(); if (gdata != null) { db.UpdatePateint(memid, model.FirstName, model.LastName, model.DateOfBirth , model.Gender, model.Address); ViewBag.message = " Profile Updated!"; return(View("EditPateint")); } else { db.InsertPateint(memid, model.FirstName, model.LastName, model.DateOfBirth, model.Gender, model.Address); ViewBag.message = "Your Profile Saved!"; return(View("EditPateint")); } } }