public ActionResult CreateStaticPagePost(Response response)
        {
            _ops = new MVCBlogOps();

            var staticPage = new StaticPage();

            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
            var user = userManager.FindById(User.Identity.GetUserId());
            if (User.IsInRole("Admin"))
            {
                // TODO: simplify this, inspect blogPost.Status
                staticPage.Status = 1; // 1 is Approved
            }
            else
            {
                staticPage.Status = 2; // 2 is Unapproved
            }

            staticPage.UserID = user.Id;
            staticPage.Title = response.StaticPage.Title;
            staticPage.Mce.Body = response.StaticPage.Mce.Body;

            _ops.SaveStaticPageToRepo(staticPage);

            return RedirectToAction("Index", "StaticPage");
        }
Esempio n. 2
0
        public ActionResult ArchivePost(BlogPost blogPost)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.ArchiveBlogPostToRepo(blogPost);
            return RedirectToAction("Index", "Home");
        }
Esempio n. 3
0
        public ActionResult ApprovePostsGet()
        {
            _ops = new MVCBlogOps();
            _res = new Response();
            _res = _ops.GetAllUnapprovedBlogPostsFromRepo();

            return View(_res);
        }
Esempio n. 4
0
        public void GetStaticPageByID_Response_ReturnResponse(bool condition, int id, bool expectedResult)
        {
            var ops = new MVCBlogOps();

            var result = ops.GetStaticPageByIDFromRepo(id);

            Assert.AreEqual(expectedResult, result.Success);
        }
        public ActionResult ArchiveStaticPage(StaticPage staticPage)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.ArchiveStaticPageToRepo(staticPage);
            return RedirectToAction("Index", "StaticPage");
        }
        public ActionResult ApproveStaticPagesGet()
        {
            _ops = new MVCBlogOps();
            _res = new Response();
            _res = _ops.GetAllUnapprovedStaticPagesFromRepo();

            return View(_res);
        }
Esempio n. 7
0
        public ActionResult CreatePostGet()
        {
            _ops = new MVCBlogOps();
            BlogPostVM blogPostVM = new BlogPostVM();
            _res = new Response();

            _res = _ops.GetAllCategoriesFromRepo();
            blogPostVM.CreateCategoriesList(_res.Categories);

            return View(blogPostVM);
        }
Esempio n. 8
0
        public ActionResult CreatePostPost(BlogPostVM blogPostVM)
        {
            _ops = new MVCBlogOps();

                var blogPost = new BlogPost();
                var userManager =
                    new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                var user = userManager.FindById(User.Identity.GetUserId());
                if (User.IsInRole("Admin"))
                {
                    blogPostVM.blogPost.Status = 1; // 1 is Approved
                    blogPost.Status = blogPostVM.blogPost.Status;
                }
                else
                {
                    blogPostVM.blogPost.Status = 2; // 2 is Unapproved
                    blogPost.Status = blogPostVM.blogPost.Status;
                }

                blogPost.User.UserID = user.Id;
                blogPost.Title = blogPostVM.blogPost.Title;
                blogPost.Mce.Body = blogPostVM.blogPost.Mce.Body;
                blogPost.Category.CategoryID = blogPostVM.category.CategoryID;

                if (blogPostVM.tags == null)
                {
                    HashTag hashTag = new HashTag();
                    hashTag.HashTagName = "#freshfoods";
                    blogPost.HashTags.Add(hashTag);
                }
                else
                {
                    foreach (var item in blogPostVM.tags)
                    {
                        HashTag hashTag = new HashTag();
                        hashTag.HashTagName = item;
                        blogPost.HashTags.Add(hashTag);
                    }
                }

            _ops.SaveBlogPostToRepo(blogPost);

            return RedirectToAction("Index", "Home");
        }
Esempio n. 9
0
        public ActionResult ViewPostsByHashTag(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetAllBlogPostsByHashTagFromRepo(id);

            return View(_res.BlogPosts);
        }
Esempio n. 10
0
        public ActionResult ViewPostsByCategory(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

               _res =  _ops.GetAllBlogPostsByCategoryFromRepo(id);
               // _res.BlogPosts
            return View(_res.BlogPosts);
        }
Esempio n. 11
0
        //[Authorize(Roles = "Admin")]
        public ActionResult ViewPostGet(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetBlogPostByIDFromRepo(id);

            return View(_res);
        }
Esempio n. 12
0
        public ActionResult Index()
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetAllApprovedBlogPostsFromRepo();
            var posts = _res.BlogPosts;
            return View(posts);
        }
Esempio n. 13
0
        public ActionResult EditPostGet(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();
            BlogPostVM blogPostVM = new BlogPostVM();

            _res = _ops.GetBlogPostByIDFromRepo(id);
            blogPostVM.blogPost = _res.BlogPost;

            blogPostVM.blogPost.HashTags = _res.BlogPost.HashTags;
            blogPostVM.blogPost.Mce.Body = _res.BlogPost.Body;
            blogPostVM.blogPost.Category = _res.BlogPost.Category;
            blogPostVM.CreateCategoriesList(_ops.GetAllCategoriesFromRepo().Categories);

            _ops.ArchiveBlogPostToRepo(blogPostVM.blogPost);//

            return View(blogPostVM);
        }
        public ActionResult EditStaticPageGet(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetStaticPageByIDFromRepo(id);

            _ops.ArchiveStaticPageToRepo(_res.StaticPage);

            return View(_res);
        }
        public ActionResult ViewStaticPageGet(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetStaticPageByIDFromRepo(id);

            return View(_res);
        }
        // GET: StaticPage
        public ActionResult Index()
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetAllApprovedStaticPagesFromRepo();
            var pages = _res.StaticPages;
            return View(pages);
        }