Beispiel #1
0
        // public ActionResult ArticleSave(string subject, string body)
        public ActionResult ArticleSave(BlogArticle model)
        { /*
           * var article = new BlogArticle();
           * // article.Subject = subject;
           * article.Subject = model.Subject;
           * // article.Body = body;
           * article.Body = model.Body;
           * article.CreTime = DateTime.Now;
           *
           * var db = new BlogDB();
           * db.BlogArticles.Add(article);
           * db.SaveChanges();*/
            if (ModelState.IsValid)
            {
                var article = new BlogArticle();
                article.Subject = model.Subject;
                article.Body    = model.Body;
                article.CreTime = DateTime.Now;

                var db = new BlogDB();
                db.BlogArticles.Add(article);
                db.SaveChanges();
            }
            return(Redirect("Index"));
            // return RedirectToAction("Index");
        }
        public IActionResult SubmitPost(BlogPost bp)
        {
            BlogDB db = new BlogDB(_connectionString);

            db.AddPost(bp);
            return(Redirect($"/Home/Index"));
        }
        public ApplicationConfiguration(BlogDB db, IContentService contentService)
        {
            this.db             = db;
            this.contentService = contentService;

            Task.WaitAll(ScanEnvironmentConfigFile());

            watcher.Path = Path.GetDirectoryName(environmentConfigFilePath);
            watcher.IncludeSubdirectories = false;
            watcher.NotifyFilter          = NotifyFilters.Attributes |
                                            NotifyFilters.CreationTime |
                                            NotifyFilters.FileName |
                                            NotifyFilters.LastAccess |
                                            NotifyFilters.LastWrite |
                                            NotifyFilters.Size |
                                            NotifyFilters.Security;
            watcher.Filter = Path.GetFileName(environmentConfigFilePath);

            watcher.Changed += async(sender, e) => {
                await ScanEnvironmentConfigFile(e.FullPath);
            };

            watcher.Created += async(sender, e) => {
                await ScanEnvironmentConfigFile(e.FullPath);
            };

            watcher.EnableRaisingEvents = true;
        }
Beispiel #4
0
        public BlogItem Get(int id)
        {
            BlogDB.PostEntry     postEntry   = BlogDB.Get(id);
            AuthorDB.AuthorEntry authorEntry = AuthorDB.Get(postEntry.AuthorId);

            BlogItem item = new BlogItem
            {
                Id          = postEntry.Id,
                Title       = postEntry.Title,
                Text        = postEntry.Text,
                CreatedDate = postEntry.CreatedDate,
                AuthorName  = authorEntry.Name
            };

            item.SelfLink   = typeof(BlogItem).CreateUri(new { Id = postEntry.Id });
            item.UpLink     = typeof(BlogList).CreateUri();
            item.AuthorLink = typeof(Author).CreateUri(new { Id = authorEntry.Id });

            if (postEntry.ImageId != null)
            {
                item.ImageLink = typeof(Image).CreateUri(new { Id = postEntry.ImageId });
            }

            return(item);
        }
        public IActionResult AddPost(Blog b)
        {
            BlogDB db = new BlogDB(_conn);

            db.AddPost(b);
            return(Redirect($"/Home/IndexPost?BlogId={b.BlogId}"));
        }
Beispiel #6
0
        public ActionResult Create()
        {
            BlogDB db = new BlogDB();

            ViewBag.KategoriId = new SelectList(db.Kategoris, "KategoriId", "KategoriAdi");
            return(View());
        }
Beispiel #7
0
        public String Search()
        {
            string username = Request["username"].ToString();


            BlogDB      blogdb   = new BlogDB();
            List <Blog> bloglist = blogdb.getBlogByUsername(username);
            String      str      = "";

            if (username == "")
            {
                bloglist = blogdb.getAllBlog();
            }
            else
            {
                if (member.ValidateUser1(username) == false)
                {
                    return("");
                }
            }
            foreach (var q in bloglist)
            {
                str += "<div class='blog' id='" + q.blogid + "'>";
                str += "<img  src=‘u=1194969155,893228591&fm=111&gp=0.jpg’ class=‘pic’/>";
                str += "<p class='name'  >" + member.getUserNameById(q.userid) + "</p>";
                str += "<p class='name'  >" + q.title + "</p>";
                str += "<button class='delete' name='bb' id='" + q.blogid + "'>删除</button>";
                str += "<input type='button' value='推荐' id='" + q.blogid + "'/></div>";
            }
            // str = " @foreach (var q in @BlogSystem.Controllers.AdminController.bloglist1){ <table id='@q.blogid' style='width:100%'><tr><td>title:</td><td>@q.title</td></tr><tr> <td>category:</td><td>@q.category</td></tr><tr> <td>updatetime:</td><td>@q.updatetime</td></tr> </table>}";
            return(str);
        }
Beispiel #8
0
        public BlogList Get()
        {
            BlogItemHandler itemHandler = new BlogItemHandler();

            BlogList list = new BlogList
            {
                Title = "A mixed blog",
            };

            list.Items = BlogDB.GetAll().Select(entry => new BlogItem
            {
                Id          = entry.AuthorId,
                Title       = entry.Title,
                Text        = entry.Text,
                CreatedDate = entry.CreatedDate,
                SelfLink    = typeof(BlogItem).CreateUri(new { Id = entry.Id })
            }).ToList();

            AuthorDB.AuthorEntry author = AuthorDB.Get(0);

            list.AuthorName = author.Name;
            list.AuthorLink = typeof(Author).CreateUri(new { Id = author.Id });
            list.EditLink   = typeof(BlogItemCreationDescriptor).CreateUri();

            // Use relative path to verify that Ramone Links/Follow/Select etc. works with rel. paths
            list.SearchDescriptionLink = BlogConstants.SearchDescriptionSubPath;

            return(list);
        }
Beispiel #9
0
        public PageModule(BlogDB db, IApplicationConfiguration config, IContentService contentService)
        {
            Get["/{slug}"] = (parameters) => {
                if (!db.Pages.Any())
                {
                    return(Response.AsError(HttpStatusCode.InternalServerError));
                }

                var fileLocation = String.Format("App_Data\\Content\\_pages\\{0}.md", parameters.slug);

                var page = db.Pages.FirstOrDefault(p => p.FileLocation == fileLocation);

                if (page == null)
                {
                    return(Response.AsError(HttpStatusCode.NotFound));
                }

                ViewBag.PageTitle = " - " + page.Title;

                return(View[page.Layout, new PageDetailViewModel {
                                Page = page,
                                EditLink = GetEditLink(config.Sync, "_pages", parameters.slug + ".md")
                            }]);
            };

            Post["/update", true] = async(parameters, ct) => {
                if (config.CanRefresh(Request))
                {
                    await contentService.GetLatestContent(config);
                }

                return(Response.AsText("Success"));
            };
        }
Beispiel #10
0
        /// <summary>
        /// Is used to either create or update an Blog.
        /// It uses the Rainbow.BlogsDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        protected override void OnUpdate(EventArgs e)
        {
            base.OnUpdate(e);

            // Only Update if Input Data is Valid
            if (Page.IsValid == true)
            {
                BlogDB blogData = new BlogDB();
                // Provide Excerpt if not present
                if (ExcerptField.Text == string.Empty)
                {
                    ExcerptField.Text = ((HTMLText)DesktopText.Text).GetAbstractText(100);
                }
                if (ItemID == 0)
                {
                    blogData.AddBlog(ModuleID, PortalSettings.CurrentUser.Identity.Email,
                                     ((HTMLText)TitleField.Text).InnerText, ((HTMLText)ExcerptField.Text).InnerText,
                                     Server.HtmlEncode(DesktopText.Text), DateTime.Parse(StartField.Text), true);
                }
                else
                {
                    blogData.UpdateBlog(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email,
                                        ((HTMLText)TitleField.Text).InnerText, ((HTMLText)ExcerptField.Text).InnerText,
                                        Server.HtmlEncode(DesktopText.Text), DateTime.Parse(StartField.Text), true);
                }
                RedirectBackToReferringPage();
            }
        }
Beispiel #11
0
        public ActionResult Edit(int id)
        {
            var db      = new BlogDB();
            var article = db.BlogArticles.First(o => o.ID == id);

            ViewData.Model = article;
            return(View());
        }
Beispiel #12
0
        // GET: Admin
        public ActionResult Index()
        {
            BlogDB db = new BlogDB();
            //Tüm makalelerimizi, tarih sırasına göre, büyükten küçüğe olmak üzere çekiyoruz.
            List <Makale> makaleListe = (from i in db.Makales orderby i.Tarih descending select i).ToList();

            return(View(makaleListe));
        }
        public IActionResult AddComment(Comments c)
        {
            BlogDB db = new BlogDB(_connectionString);

            db.AddComment(c);
            Response.Cookies.Append("name", c.CommenterName);
            return(Redirect($"/Home/ViewBlog?id={c.BlogPostId}"));
        }
        public IActionResult AddComment(BlogComment c)
        {
            Response.Cookies.Append("authorCookie", $"{c.CommentAuthor}");//sets/updates the cookie

            BlogDB db = new BlogDB(_conn);

            db.AddComment(c);
            return(Redirect($"/Home/IndexPost?blogId={ c.BlogId}"));
        }
Beispiel #15
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            BlogPost blog = await BlogDB.GetBlogPostById(id, _context);

            await BlogDB.Delete(blog, _context);

            TempData["Message"] = $"{blog.Title} deleted successfully";
            return(RedirectToAction(nameof(BlogPostIndex)));
        }
Beispiel #16
0
        /// <summary>
        /// 删除博文
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            var db      = new BlogDB();
            var article = db.BlogArticles.First(o => o.ID == id);

            db.BlogArticles.Remove(article);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public IActionResult Index()
        {
            BlogDB            db = new BlogDB(_connectionString);
            BlogPostViewModel vm = new BlogPostViewModel
            {
                Blogs = db.GetBlogPosts(),
            };

            return(View(vm));
        }
        public IActionResult IndexPost(int blogId)
        {
            BlogDB        db = new BlogDB(_conn);
            BlogViewModel vm = new BlogViewModel();

            vm.Blog         = db.GetSinglePost(blogId);
            vm.Comments     = db.GetComments(blogId);
            vm.AuthorCookie = Request.Cookies["authorCookie"];
            return(View(vm));
        }
 protected void dlComments_ItemCommand(object source, DataListCommandEventArgs e)
 {
     if (e.CommandName == "DeleteComment")
     {
         BlogDB blogDB = new BlogDB();
         blogDB.DeleteBlogComment(int.Parse(e.CommandArgument.ToString()));
         Response.Clear();
         Response.Redirect(Request.Url.ToString());
     }
 }
Beispiel #20
0
        public async Task <IActionResult> Delete(int id)
        {
            BlogPost blog = await BlogDB.GetBlogPostById(id, _context);

            if (blog == null)
            {
                return(NotFound());
            }

            return(View(blog));
        }
        public IActionResult ViewBlog(int id)
        {
            BlogDB db = new BlogDB(_connectionString);
            SinglePostViewModel vm = new SinglePostViewModel
            {
                Blogs     = db.GetPost(id),
                Commenter = Request.Cookies["name"]
            };

            return(View(vm));
        }
Beispiel #22
0
        public string updateblog()
        {
            string blogid = Request["blogid"].ToString();
            string title  = Request["title"].ToString();
            //  String q = Server.HtmlEncode(Request["val1"].ToString());
            String content = Server.HtmlEncode(Request["content"].ToString());
            string category = Request["category"].ToString();
            string authority = Request["authority"].ToString(); BlogDB blogdb = new BlogDB();

            return(blogdb.ChangeBlog(title, content, category, authority, Int32.Parse(blogid)));
        }
        /// <summary>
        /// The BindData method is used to obtain details of a message
        /// from the Blogs table, and update the page with
        /// the message content.
        /// </summary>
        private void BindData()
        {
            // Obtain the selected item from the Blogs table
            BlogDB        blogDB     = new BlogDB();
            SqlDataReader dataReader = blogDB.GetSingleBlog(ItemID);

            try
            {
                // Load first row from database
                if (dataReader.Read())
                {
                    // Update labels with message contents
                    Title.Text       = (string)dataReader["Title"].ToString();
                    txtTitle.Text    = "re: " + (string)dataReader["Title"].ToString();
                    StartDate.Text   = ((DateTime)dataReader["StartDate"]).ToString("dddd MMMM d yyyy hh:mm tt");
                    Description.Text = Server.HtmlDecode((string)dataReader["Description"].ToString());
                }
            }
            finally
            {
                dataReader.Close();
            }
            dlComments.DataSource = blogDB.GetBlogComments(ModuleID, ItemID);
            dlComments.DataBind();

            if (Request.Params.Get("blogUser") != null)
            {
                txtName.Text = Request.Params.Get("blogUser");
            }
            if (Request.Params.Get("blogUrl") != null)
            {
                txtURL.Text = Request.Params.Get("blogUrl");
            }

            dlArchive.DataSource = blogDB.GetBlogMonthArchive(ModuleID);
            dlArchive.DataBind();

            dataReader = blogDB.GetBlogStats(ModuleID);
            try
            {
                if (dataReader.Read())
                {
                    lblEntryCount.Text = General.GetString("BLOG_ENTRIES", "Entries", null) +
                                         " (" + (string)dataReader["EntryCount"].ToString() + ")";
                    lblCommentCount.Text = General.GetString("BLOG_COMMENTS", "Comments", null) +
                                           " (" + (string)dataReader["CommentCount"].ToString() + ")";
                }
            }
            finally
            {
                dataReader.Close();
            }
        }
        public IActionResult MostRecent()
        {
            BlogDB db = new BlogDB(_connectionString);
            IEnumerable <BlogPost> blogPosts = db.GetBlogPosts();
            SinglePostViewModel    vm        = new SinglePostViewModel
            {
                Blogs     = blogPosts.FirstOrDefault(),
                Commenter = Request.Cookies["name"]
            };

            return(View(vm));
        }
Beispiel #25
0
        public async Task <IActionResult> Edit(BlogPost blog)
        {
            if (ModelState.IsValid)
            {
                await BlogDB.Edit(blog, _context);

                ViewData["Message"] = blog.Title + " updated successfully";
                return(View(blog));
            }

            return(View(blog));
        }
Beispiel #26
0
        public async Task <IActionResult> Add(BlogPost blog)
        {
            if (ModelState.IsValid)
            {
                await BlogDB.Add(blog, _context);

                TempData["Message"] = $"{blog.Title} added successfully";
                return(RedirectToAction(nameof(BlogPostIndex)));
            }

            return(View());
        }
Beispiel #27
0
 /// <summary>
 /// The DeleteBtn_Click event handler on this Page is used to delete an
 /// a Blog.  It  uses the Rainbow.BlogsDB()
 /// data component to encapsulate all data functionality.
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDelete(EventArgs e)
 {
     base.OnDelete(e);
     // Only attempt to delete the item if it is an existing item
     // (new items will have "ItemID" of 0)
     if (ItemID != 0)
     {
         BlogDB blogData = new BlogDB();
         blogData.DeleteBlog(ItemID);
     }
     RedirectBackToReferringPage();
 }
Beispiel #28
0
        public ActionResult EditSave(int id, string subject, string body)
        {
            var db      = new BlogDB();
            var article = db.BlogArticles.First(o => o.ID == id);

            article.Subject = subject;
            article.Body    = body;

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #29
0
        /// <summary>
        /// Binds the archive.
        /// </summary>
        private void BindArchive()
        {
            lnkRSS.HRef       = HttpUrlBuilder.BuildUrl("~/DesktopModules/CommunityModules/Blog/RSS.aspx", PageID, "&mID=" + ModuleID);
            imgRSS.Src        = HttpUrlBuilder.BuildUrl("~/DesktopModules/CommunityModules/Blog/xml.gif");
            lblCopyright.Text = moduleSettings["Copyright"].ToString();

            BlogDB blogDB = new BlogDB();
            int    month  = -1;
            int    year   = -1;

            try
            {
                month = int.Parse(Request.Params.Get("month"));
                year  = int.Parse(Request.Params.Get("year"));
            }
            catch
            {
            }

            if ((month > -1) && (year > -1))
            {
                lblHeader.Text = (String)HttpContext.GetGlobalResourceObject("Rainbow", "BLOG_POSTSFROM") +
                                 " " + DateTime.Parse(month.ToString() + "/1/" + year.ToString()).ToString("MMMM, yyyy");
                myDataList.DataSource = blogDB.GetBlogEntriesByMonth(month, year, ModuleID);
            }
            else
            {
                myDataList.DataSource = blogDB.GetBlogs(ModuleID);
            }
            myDataList.DataBind();

            dlArchive.DataSource = blogDB.GetBlogMonthArchive(ModuleID);
            dlArchive.DataBind();

            SqlDataReader dataReader = blogDB.GetBlogStats(ModuleID);

            try
            {
                if (dataReader.Read())
                {
                    lblEntryCount.Text = (String)HttpContext.GetGlobalResourceObject("Rainbow", "BLOG_ENTRIES") +
                                         " (" + dataReader["EntryCount"].ToString() + ")";
                    lblCommentCount.Text = (String)HttpContext.GetGlobalResourceObject("Rainbow", "BLOG_COMMENTS") +
                                           " (" + dataReader["CommentCount"].ToString() + ")";
                }
            }
            finally
            {
                dataReader.Close();
            }
        }
 protected void btnPostComment_Click(object sender, EventArgs e)
 {
     if (IsValidComment())
     {
         if (chkRememberMe.Checked)
         {
             SetCookies();
         }
         BlogDB blogDB = new BlogDB();
         blogDB.AddBlogComment(ModuleID, ItemID, txtName.Text,
                               txtTitle.Text, txtURL.Text, txtComments.Text);
         Response.Redirect(Request.Url.ToString());
     }
 }