// GET: Admin
        //[Authorize(Roles = "Admin")]
        public ActionResult Index()
        {
            var manager = new BlogManager();
            var response = manager.GetAllApprovedPosts();

            return View(response.Data);
        }
        public ActionResult CreateWebpage(Webpage page)
        {
            var manager = new BlogManager();
            manager.AddWebpage(page);

            return RedirectToAction("Index/"+ page.Title, "Static");
        }
        // GET: Static
        public ActionResult Index(string Title)
        {
            var manager = new BlogManager();
            var page = manager.GetWebpageByTitle(Title).Data;

            return View(page);
        }
        public ActionResult Approve(Array checkedIds)
        {
            var postID = new List<int>();

            foreach (string p in checkedIds)
            {
                postID.Add(int.Parse(p));
            }

            var manager = new BlogManager();
            manager.ApprovePost(postID);

            return RedirectToAction("Index");
        }
        public ActionResult CreatePost(Models.HTMLContent x)
        {
            if(ModelState.IsValid)
            {
            var newPost = new Post();
            newPost.Content = x.HtmlContent;
            newPost.Title = x.Title;
            newPost.IsApproved = false;
            newPost.DatePosted = DateTime.Now;

            var manager = new BlogManager();
            var response = manager.AddPost(newPost);

            return View("Pending");
            }
            else
            {
                return View("NewAdminPost");
            }
        }
        public ActionResult CreatePost(HTMLContent x)
        {
            var newPost = new Domain.Post();

            newPost.Content = x.HtmlContent;
            newPost.Title = x.Title;
            newPost.IsApproved = true;
            newPost.DatePosted = DateTime.Now;

            if (ModelState.IsValid)
            {
                var manager = new BlogManager();
                var response = manager.AddPost(newPost);

                return RedirectToAction("Index");
            }
            else
            {
                return View("OwnerAddPost");
            }
        }
 public ActionResult UnapprovedPosts()
 {
     var manager = new BlogManager();
     var data = manager.GetAllUnapprovedPosts().Data;
     return View(data);
 }
        public ActionResult OwnerDelete(Array checkedBoxes)
        {
            var postID = new List<int>();
            foreach(string ID in checkedBoxes)
            {
                postID.Add(int.Parse(ID));
            }
            var manager = new BlogManager();
            manager.DeletePost(postID);

            return RedirectToAction("Index");
        }
 public List<Post> Get()
 {
     var manager = new BlogManager();
     var data = manager.GetAllUnapprovedPosts().Data;
     return data;
 }