public ActionResult Create(OwnerProfile ownerprofile)
 {
     if (ModelState.IsValid) {
         ownerprofileRepository.InsertOrUpdate(ownerprofile);
         ownerprofileRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
 public void InsertOrUpdate(OwnerProfile ownerprofile)
 {
     if (ownerprofile.OwnerProfileId == default(int)) {
         // New entity
         context.OwnerProfiles.Add(ownerprofile);
     } else {
         // Existing entity
         context.Entry(ownerprofile).State = EntityState.Modified;
     }
 }