示例#1
0
        // 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);
        }
示例#2
0
        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 }
                };
            }

        }
示例#3
0
        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 }
                };
            }

        }