Example #1
0
        public ActionResult ArticleManage(ArticleQuery q)
        {
            emailableModel <Article> aArticle = new emailableModel <Article>();

            aArticle.model = smokeFreeDB.Article.Find(q.id);
            return(View(aArticle));
        }
Example #2
0
        public ActionResult ClosePost(ArticleQuery q)
        {
            var article = smokeFreeDB.Article.Find(q.id);

            if (article.articleStatus == "approved")
            {
                ViewBag.activeTabContent = "Approved Article";
            }
            else
            {
                ViewBag.activeTabContent = "Pending Article";
            }

            return(View("Manage", populateView()));
        }
Example #3
0
        public ActionResult NextPost(ArticleQuery q)
        {
            var article  = smokeFreeDB.Article.Find(q.id);
            var articles = from a in smokeFreeDB.Article
                           where a.articleStatus == article.articleStatus
                           select a;

            var articlesList = articles.ToList();
            int index        = articlesList.FindIndex(a => a.articleID == q.id);
            var nextarticle  = article;

            if (index + 1 < articlesList.Count())
            {
                nextarticle = articlesList.ElementAt(++index);
            }


            return(RedirectToAction("ArticleManage", new SmokeFreeApplication.Controllers.ArticleQuery(nextarticle.articleID)));
        }
Example #4
0
        public ActionResult ApprovePost(ArticleQuery q)
        {
            var article = smokeFreeDB.Article.Find(q.id);

            article.articleStatus = "approved";
            smokeFreeDB.SaveChanges();

            try
            {
                const string systemEmail   = "*****@*****.**";
                const string systemEmailPw = "Omaewamou"; // dont hack me , thx
                MailMessage  mail          = new MailMessage();
                //string testEmail = "*****@*****.**";
                var aDoc = smokeFreeDB.GeneralUser.Find(article.userName);
                mail.To.Add(aDoc.email);
                mail.From    = new MailAddress(systemEmail);
                mail.Subject = "Article Accepted - Thank you for your submission";
                mail.Body    = "Hi Sir/Mdm,\n Welcome! We have decided to accept your article.\n Thank you";

                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential(systemEmail, systemEmailPw); // Enter senders User name and password
                smtp.EnableSsl             = true;
                smtp.Send(mail);
            }
            catch (Exception e)
            {
                //hmmm....
            }

            ViewBag.activeTabContent = "Pending Article";
            return(View("Manage", populateView()));
        }