public ActionResult AddEditAddressBook(AddressBookModel model) { if (ModelState.IsValid) //checking model is valid or not { DbData objDB = new DbData(); //calling class DBdata string result = string.Empty; if (model.ID.HasValue) { result = objDB.UpdateData(model); // passing Value to DBClass from model } else { result = objDB.InsertData(model); } ViewData["result"] = result; ModelState.Clear(); //clearing model return(RedirectToActionPermanent("ManageAddressBook")); // return View(); } else { // ModelState.AddModelError("", "Error in saving data"); return(View(new AddressBookModel())); } }