Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        public ActionResult ArchivePost(BlogPost blogPost)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

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

            return View(_res);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public ActionResult ArchiveStaticPage(StaticPage staticPage)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

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

            return View(_res);
        }
Ejemplo 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);
        }
Ejemplo 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");
        }
Ejemplo n.º 9
0
        public ActionResult ViewPostsByHashTag(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetAllBlogPostsByHashTagFromRepo(id);

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

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

            _res = _ops.GetBlogPostByIDFromRepo(id);

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

            _res = _ops.GetAllApprovedBlogPostsFromRepo();
            var posts = _res.BlogPosts;
            return View(posts);
        }
Ejemplo 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);
        }
Ejemplo n.º 14
0
        public ActionResult EditStaticPageGet(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetStaticPageByIDFromRepo(id);

            _ops.ArchiveStaticPageToRepo(_res.StaticPage);

            return View(_res);
        }
Ejemplo n.º 15
0
        public ActionResult ViewStaticPageGet(int id)
        {
            _res = new Response();
            _ops = new MVCBlogOps();

            _res = _ops.GetStaticPageByIDFromRepo(id);

            return View(_res);
        }
Ejemplo n.º 16
0
        // GET: StaticPage
        public ActionResult Index()
        {
            _res = new Response();
            _ops = new MVCBlogOps();

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