Пример #1
0
        public ActionResult Create(string name, int[] posts)
        {
            if (String.IsNullOrEmpty(name))
            {
                return(Json(new { result = "error", message = @Resources.AppMessages.RequiredFields }));
            }
            if (posts == null)
            {
                return(Json(new { result = "error", message = @Resources.AppMessages.NoPostsSelected }));
            }
            List <Post> newsletterPosts = new List <Post>();

            foreach (int postid in posts)
            {
                Post post = PostServices.FindAllEntities(p => p.PostId == postid, null, "Image").First();
                newsletterPosts.Add(post);
            }
            NewsletterServices.CreateNewsletter(name, UserMailer.GetNewsletterHtml(newsletterPosts, name).Body);
            return(Json(new { result = "ok" }));
        }