Ejemplo n.º 1
0
        public JsonResult AddNewsLetter([FromBody] NewsLetter newsletter)
        {
            if (!newsletter.Email.EmailValidation())
            {
                return(Json("Email Is Not Valid"));
            }

            newsletter.Email = Sanitizer.GetSafeHtmlFragment(newsletter.Email);
            newsletter.Email = newsletter.Email.Trim();
            if (newsletter.Email.Equals(null) || newsletter.Email.Equals(""))
            {
                return(Json("reject"));
            }
            bool result = service.AddNewsLetter(newsletter.Email);

            service.SaveChanges();
            return(result ? Json("accept") : Json("reject"));
        }