Exemplo n.º 1
0
        public IActionResult Contact(ContactMessage contact)
        {
            ContactMessage cm = new ContactMessage
            {
                CreatedDate = DateTime.Now,
                EmailUser   = contact.EmailUser,
                IPAddress   = contact.IPAddress,
                Message     = contact.Message,
                Name        = contact.Name,
                UserAgent   = Request.Headers["User-Agent"]
            };

            _context.ContactMessage.Add(cm);

            try
            {
                _context.SaveChanges();
                ViewBag.Message = "Terima kasih telah menghubungi kami.";
            }
            catch
            {
                ViewBag.Message = "Mohon maaf, terdapat kesalahan di sistem. Silahkan input pesan kembali.";
            }
            return(View());
        }
Exemplo n.º 2
0
        public IActionResult _Contact(ContactMessage contact)
        {
            ContactMessage cm = new ContactMessage();

            cm.CreatedDate = DateTime.Now;
            cm.EmailUser   = contact.EmailUser;
            cm.IPAddress   = contact.IPAddress;
            cm.Message     = contact.Message;
            cm.Name        = contact.Name;
            cm.UserAgent   = Request.Headers["User-Agent"];


            _context.ContactMessage.Add(cm);
            var message = "";

            try
            {
                _context.SaveChanges();
                message = "Terima kasih telah menghubungi kami.";
            }
            catch
            {
                message = "Mohon maaf, terdapat kesalahan di sistem. Silahkan input pesan kembali.";
            }

            var routeValues = new RouteValueDictionary
            {
                { "message", message }
            };

            return(Redirect(Url.RouteUrl(new { controller = "Home", action = "Index" }) + "?message=" + message + "#contact"));
        }