public ActionResult EditContact(int id = 0) { if (id == 0) { return(RedirectToAction("HomeSetting")); } var temp = new ContactSMModels(); using (DataBaseContext db = new DataBaseContext()) { temp = db.Contact.FirstOrDefault(m => m.Id == id); } return(View(temp)); }
public ActionResult ContactSave(ContactSMModels model) { if (ModelState.IsValid && model != null) { using (DataBaseContext db = new DataBaseContext()) { var temp = db.Contact.FirstOrDefault(m => m.Id == model.Id); temp.active = model.active; temp.value = model.value; temp.symbol = model.symbol; temp.Name = model.Name; db.SaveChanges(); } return(RedirectToAction("HomeSetting")); } else { return(RedirectToAction("EditContact", new { id = model.Id })); } }