public ActionResult Review(int id)
        {
            BlogManager manager  = BlogManagerFactory.Create();
            BlogPost    toReview = manager.GetBlog(id);

            foreach (var tag in toReview.SearchTags)
            {
                if (toReview.TagInputs == null)
                {
                    toReview.TagInputs = tag.SearchTagBody;
                }
                else
                {
                    toReview.TagInputs = (toReview.TagInputs + "," + tag.SearchTagBody);
                }
            }

            UserManager <AppUser> userMgr = new UserManager <AppUser>(new UserStore <AppUser>(new TheCodingVineDbContext()));
            var users = userMgr.Users;

            var blogVM = new BlogVM();

            blogVM.SetBlog(toReview);
            blogVM.SetBlogWriters(users);

            return(View(blogVM));
        }
示例#2
0
        private void GetAllUsers()
        {
            BlogManager manager = BlogManagerFactory.Create();
            var         users   = manager.GetAllUsers();

            SetUserList(users);
        }
        public ActionResult DeleteABlog(BlogVM blogVM)
        {
            BlogManager manager = BlogManagerFactory.Create();

            manager.DeleteBlog(blogVM.Blog.BlogPostId);
            return(RedirectToAction("MyBlogs"));
        }
        public ActionResult Review(BlogVM model)
        {
            BlogManager manager = BlogManagerFactory.Create();

            if (model.Blog.TagInputs != null)
            {
                string[] tags = model.Blog.TagInputs.Split(',');

                foreach (var tag in tags)
                {
                    var searchTag = new SearchTag()
                    {
                        SearchTagBody = tag
                    };

                    model.Blog.SearchTags.Add(searchTag);
                }

                model.Blog.TagInputs = null;
            }

            manager.UpdateBlog(model.Blog);

            return(RedirectToAction("ViewPending"));
        }
示例#5
0
        private void GetStaticLinks()
        {
            BlogManager manager      = BlogManagerFactory.Create();
            var         siteLinkList = manager.GetSiteLinks();

            SetStaticLinks(siteLinkList);
        }
        public ActionResult EditABlog(BlogVM blogVM)
        {
            BlogManager manager = BlogManagerFactory.Create();

            if (blogVM.Blog.TagInputs != null)
            {
                string[] tags = blogVM.Blog.TagInputs.Split(',');

                foreach (var tag in tags)
                {
                    var searchTag = new SearchTag()
                    {
                        SearchTagBody = tag
                    };

                    blogVM.Blog.SearchTags.Add(searchTag);
                }

                blogVM.Blog.TagInputs = null;
            }

            manager.UpdateBlog(blogVM.Blog);

            return(RedirectToAction("MyBlogs"));
        }
        public ActionResult EditABlog(int id)
        {
            BlogManager manager    = BlogManagerFactory.Create();
            var         blogToEdit = manager.GetBlog(id);

            UserManager <AppUser> userMgr = new UserManager <AppUser>(new UserStore <AppUser>(new TheCodingVineDbContext()));
            var users = userMgr.Users;

            foreach (var tag in blogToEdit.SearchTags)
            {
                if (blogToEdit.TagInputs == null)
                {
                    blogToEdit.TagInputs = tag.SearchTagBody;
                }
                else
                {
                    blogToEdit.TagInputs = (blogToEdit.TagInputs + "," + tag.SearchTagBody);
                }
            }

            var blogVM = new BlogVM();

            blogVM.SetBlog(blogToEdit);
            blogVM.SetBlogWriters(users);

            return(View(blogVM));
        }
示例#8
0
        public ActionResult EditStaticPost(PostVM postVM)
        {
            BlogManager manager = BlogManagerFactory.Create();

            manager.UpdateStaticPost(postVM.Post);

            return(RedirectToAction("ViewStaticPosts"));
        }
示例#9
0
        public ActionResult CreateStaticPost(PostVM model)
        {
            BlogManager manager = BlogManagerFactory.Create();

            manager.AddPost(model.Post);

            return(RedirectToAction("ViewStaticPosts"));
        }
示例#10
0
        public ActionResult CreateStaticPost()
        {
            BlogManager manager = BlogManagerFactory.Create();

            var postVM = new PostVM();

            return(View(postVM));
        }
示例#11
0
        public ActionResult DeleteStaticPost(PostVM postVM)
        {
            BlogManager manager = BlogManagerFactory.Create();

            manager.DeleteStaticPost(postVM.Post.StaticPostId);

            return(RedirectToAction("ViewStaticPosts"));
        }
        public ActionResult DeleteABlogger(AppUser toDelete)
        {
            BlogManager manager = BlogManagerFactory.Create();

            manager.DeleteBlogger(toDelete.UserName);

            return(RedirectToAction("MyBloggers"));
        }
        public ActionResult DeleteUser(UserViewModel toDelete)
        {
            BlogManager manager = BlogManagerFactory.Create();

            var userToDelete = toDelete.User;

            manager.DeleteBlogger(userToDelete.UserName);

            return(RedirectToAction("AllUsers"));
        }
        public ActionResult DeleteABlogger(string id)
        {
            BlogManager manager = BlogManagerFactory.Create();

            var userVM = new UserViewModel();

            userVM.SetUser(id);

            return(View(userVM));
        }
        public ActionResult ViewPending()
        {
            BlogManager manager  = BlogManagerFactory.Create();
            var         blogRoll = manager.GetAllPending();

            var blogRollVM = new BlogRollVM();

            blogRollVM.SetBlogRoll(blogRoll);

            return(View(blogRollVM));
        }
示例#16
0
        public ActionResult ViewStaticPosts()
        {
            BlogManager manager  = BlogManagerFactory.Create();
            var         postList = manager.GetAllStaticPosts();

            var postListVM = new PostListVM();

            postListVM.SetPostList(postList);

            return(View(postListVM));
        }
示例#17
0
        public ActionResult DeleteStaticPost(int id)
        {
            BlogManager manager      = BlogManagerFactory.Create();
            var         postToDelete = manager.GetStaticPost(id);

            var postVM = new PostVM();

            postVM.SetPost(postToDelete);

            return(View(postVM));
        }
        public ActionResult EditABlogger(string id)
        {
            BlogManager manager = BlogManagerFactory.Create();

            var bloggerToEdit = manager.GetBlogger(id);
            var editVM        = new EditUserViewModel();

            editVM.SetUser(bloggerToEdit);

            return(View(editVM));
        }
        public ActionResult ViewBlog(int id)
        {
            BlogManager manager = BlogManagerFactory.Create();
            var         blog    = manager.GetBlog(id);

            var blogVM = new BlogVM();

            blogVM.SetPost(blog);

            return(View(blogVM));
        }
        public ActionResult ViewSearchResults(string searchTag)
        {
            BlogManager manager       = BlogManagerFactory.Create();
            var         blogRoll      = manager.GetSearchResults(searchTag);
            var         approvedBlogs = blogRoll.Where(b => b.IsApproved == true).Where(d => d.PostDate <= DateTime.Now);

            var blogRollVM = new BlogRollVM();

            blogRollVM.SetBlogRoll(approvedBlogs);

            return(View(blogRollVM));
        }
        public ActionResult MyBloggers()
        {
            BlogManager manager = BlogManagerFactory.Create();

            var bloggers = manager.GetAllBloggers();

            var userVm = new UsersViewModel();

            userVm.SetUserList(bloggers);
            // need a userVM

            return(View(userVm));
        }
        public ActionResult Index()
        {
            BlogManager manager       = BlogManagerFactory.Create();
            var         blogRollVM    = new BlogRollVM();
            var         blogRoll      = manager.GetAllBlogs();
            var         approvedBlogs = blogRoll.Where(a => a.IsApproved == true).Where(d => d.PostDate <= DateTime.Now);

            var blogWriters = manager.GetAllBloggers();

            blogRollVM.SetBlogRoll(approvedBlogs);
            blogRollVM.SetUsers(blogWriters);

            return(View(blogRollVM));
        }
        public ActionResult ViewSingleAll(int id)
        {
            BlogManager manager = BlogManagerFactory.Create();
            var         blog    = manager.GetBlog(id);

            UserManager <AppUser> userMgr = new UserManager <AppUser>(new UserStore <AppUser>(new TheCodingVineDbContext()));
            var users = userMgr.Users;

            var blogVM = new BlogVM();

            blogVM.SetBlog(blog);
            blogVM.SetBlogWriters(users);

            return(View(blogVM));
        }
        public ActionResult GetAllBlogs()
        {
            BlogManager manager  = BlogManagerFactory.Create();
            var         blogRoll = manager.GetAllBlogs();

            UserManager <AppUser> userMgr = new UserManager <AppUser>(new UserStore <AppUser>(new TheCodingVineDbContext()));
            var users = userMgr.Users;

            var blogRollVM = new BlogRollVM();

            blogRollVM.SetBlogRoll(blogRoll);
            blogRollVM.SetUsers(users);

            return(View(blogRollVM));
        }
        public ActionResult AddBlogPost(BlogVM model)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(model.Blog.Title))
                {
                    ModelState.AddModelError("Title", "You must enter a title.");
                }
                else if (string.IsNullOrEmpty(model.Blog.Content))
                {
                    ModelState.AddModelError("Content", "You must enter something in the blog body.");
                }
                else
                {
                    TheCodingVineDbContext db = new TheCodingVineDbContext();


                    BlogManager manager = BlogManagerFactory.Create();

                    if (model.Blog.TagInputs != null)
                    {
                        string[] tags = model.Blog.TagInputs.Split(',');

                        foreach (var tag in tags)
                        {
                            var searchTag = new SearchTag()
                            {
                                SearchTagBody = tag
                            };
                            model.Blog.SearchTags.Add(searchTag);
                        }

                        model.Blog.TagInputs = null;
                    }

                    UserManager <AppUser> userManager = new UserManager <AppUser>(new UserStore <AppUser>(db));

                    model.Blog.BlogWriter = userManager.FindByName(User.Identity.Name);

                    manager.AddBlog(model.Blog);

                    return(RedirectToAction("MyBlogs"));
                }
            }

            return(View(model));
        }
        public ActionResult ViewSearchResults(string searchTag)
        {
            BlogManager manager       = BlogManagerFactory.Create();
            var         blogRoll      = manager.GetSearchResults(searchTag);
            var         approvedBlogs = blogRoll.Where(a => a.IsApproved == true)
                                        .Where(d => d.PostDate <= DateTime.Now);

            UserManager <AppUser> userMgr = new UserManager <AppUser>(new UserStore <AppUser>(new TheCodingVineDbContext()));
            var users = userMgr.Users;

            var blogRollVM = new BlogRollVM();

            blogRollVM.SetBlogRoll(approvedBlogs);
            blogRollVM.SetUsers(users);

            return(View(blogRollVM));
        }
        public async Task <ActionResult> VerifyCode(string provider, string returnUrl, bool rememberMe)
        {
            var verifyCodeVM = new VerifyCodeViewModel {
                Provider = provider, ReturnUrl = returnUrl, RememberMe = rememberMe
            };
            BlogManager manager   = BlogManagerFactory.Create();
            var         siteLinks = manager.GetSiteLinks();

            //verifyCodeVM.SetStaticLinks(siteLinks);

            // Require that the user has already logged in via username/password or external login
            if (!await SignInManager.HasBeenVerifiedAsync())
            {
                return(View("Error"));
            }
            return(View(verifyCodeVM));
        }
        public ActionResult EditABlog(int id)
        {
            BlogManager manager    = BlogManagerFactory.Create();
            var         blogToEdit = manager.GetBlog(id);

            foreach (var tag in blogToEdit.SearchTags)
            {
                if (blogToEdit.TagInputs == null)
                {
                    blogToEdit.TagInputs = tag.SearchTagBody;
                }
                else
                {
                    blogToEdit.TagInputs = (blogToEdit.TagInputs + "," + tag.SearchTagBody);
                }
            }

            var blogVM = new BlogVM();

            blogVM.SetPost(blogToEdit);

            return(View(blogVM));
        }
        public ActionResult Review(int id)
        {
            BlogManager manager   = BlogManagerFactory.Create();
            BlogPost    toReview  = manager.GetBlog(id);
            var         siteLinks = manager.GetSiteLinks();

            foreach (var tag in toReview.SearchTags)
            {
                if (toReview.TagInputs == null)
                {
                    toReview.TagInputs = tag.SearchTagBody;
                }
                else
                {
                    toReview.TagInputs = (toReview.TagInputs + "," + tag.SearchTagBody);
                }
            }

            var blogVM = new BlogVM();

            blogVM.SetPost(toReview);

            return(View(blogVM));
        }