public ActionResult Create(UserPhones userphones) { try { //Int64 userPhnid = Convert.ToInt64(userphones.UserPhoneId); if (userphones.UserPhoneId == 0) { db.tabUserPhones.Add(userphones); db.SaveChanges(); return PartialView("Create"); } else { UserPhones uObj = db.tabUserPhones.Find(userphones.UserPhoneId); uObj.UserPhoneId = userphones.UserPhoneId; uObj.PhoneNumber = userphones.PhoneNumber; db.Entry(uObj).State = EntityState.Modified; db.SaveChanges(); return PartialView("Create"); } } catch (Exception) { throw; } //if (ModelState.IsValid) //{ // db.UserPhones.Add(userphones); // db.SaveChanges(); // return RedirectToAction("Index"); //} //return View(userphones); }
public ActionResult Edit(UserPhones userphones) { if (ModelState.IsValid) { db.Entry(userphones).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(userphones); }