Пример #1
0
        public ActionResult SignUpNewLetter(string email)
        {
            var data = new object();

            try
            {
                NewsLetter letter = new NewsLetter()
                {
                    Email = email,
                    DateCreated = DateTime.Now
                };
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    db.NewsLetters.Add(letter);
                    db.SaveChanges();
                }

            }
            catch (Exception ex)
            {
                data = new { success = false, message = "Failed to join news letter." };
                return Json(data);
            }

            data = new { success = true };

            return Json(data);
        }
Пример #2
0
        public ActionResult SendContactEmail(ContactMailModel model)
        {
            var data = new object();

            try
            {
                var email = EmailMessageFactory.GetContactEmail(model);
                var result = EmailClient.SendEmail(email);

                if (!String.IsNullOrEmpty(model.NewsLetter))
                {
                    try
                    {
                        NewsLetter letter = new NewsLetter()
                        {
                            Email = model.Email,
                            DateCreated = DateTime.Now
                        };
                        using (var db = new DIYFE.EF.DIYFEEntities())
                        {
                            db.NewsLetters.Add(letter);
                            db.SaveChanges();
                        }

                    }
                    catch (Exception ex)
                    {
                        data = new { success = false, message = "Message Was Sent...but failed to join news letter." };
                        return Json(data);
                    }
                }
            }
            catch (Exception ex)
            {
                data = new { success = false, message = "Failed to send comment.  Please trying contacting us directly." };
                return Json(data);
            }

            data = new { success = true };

            return Json(data);
        }