// GET: Contact public ActionResult Index() { var Contacts = db.Contact.First(); ContactSummaryViewModel _Contact = new ContactSummaryViewModel() { Address = Contacts.Address, Email = Contacts.Email, Phone = Contacts.Phone, Fax = Contacts.Fax, Link = Contacts.Link }; return View(_Contact); }
public ActionResult EditContactSubmit(int id, string address, string phone, string fax, string email, string link, int echo) { var Contacts = db.Contact.Find(id); Contacts.Address = address; Contacts.Phone = phone; Contacts.Fax = fax; Contacts.Email = email; Contacts.Link = link; db.SaveChanges(); ContactSummaryViewModel _Contact = new ContactSummaryViewModel() { Address = Contacts.Address, Phone = Contacts.Phone, Fax = Contacts.Fax, Email = Contacts.Email, Link = Contacts.Link }; var view_str = RazorViewToString.RenderRazorViewToString(this, "Partial/_Contact", _Contact); try { return new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = "success", echo = echo, html = view_str } }; } catch (Exception ex) { return new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = "fail", message = ex.Message } }; } }
public ActionResult EditContact(int id, string address, string phone, string fax, string email, string link, int echo) { try { ContactSummaryViewModel _Contact = new ContactSummaryViewModel() { ID = id, Address = address, Phone = phone, Fax = fax, Email = email, Link = link }; var view_str = RazorViewToString.RenderRazorViewToString(this, "Partial/_ContactEdit", _Contact); return new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = "success", echo = echo, html = view_str } }; } catch (Exception ex) { return new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = "fail", message = ex.Message } }; } }