Esempio n. 1
0
 public static Blog GetBlogByBlogID(Int64 BlogID)
 {
     Blog result = new Blog();
         result = All().Where(b => b.BlogID == BlogID).FirstOrDefault();
         Account account = Account.All().Where(a => a.AccountID == result.AccountID).FirstOrDefault();
         result.AccountID = account.AccountID;
     return result;
 }
Esempio n. 2
0
 public void LoadPost(Blog blog)
 {
     txtTitle.Text = blog.Title;
     txtSubject.Text = blog.Subject;
     txtMessage.Value = blog.Post;
     txtPageName.Text = blog.PageName;
     chkIsPublished.Checked = blog.IsPublished;
     litBlogID.Text = blog.BlogID.ToString();
 }
Esempio n. 3
0
 public static bool CheckPageNameIsUnique(Blog blog)
 {
     blog = CleanPageName(blog);
     bool result = true;
         int count = All().Where(b => b.PageName == blog.PageName && b.AccountID == blog.AccountID).Count();
         if (count > 0)
             result = false;
     return result;
 }
Esempio n. 4
0
        public static Blog GetBlogByPageName(string PageName, Int32 AccountID)
        {
            Blog result = new Blog();

            result = All().Where(b => b.PageName == PageName && b.AccountID == AccountID).FirstOrDefault();
                //result = dc.Blogs.Where(b => b.PageName == PageName && b.AccountID == AccountID).FirstOrDefault();

            return result;
        }
Esempio n. 5
0
 public void LoadPost(Blog blog)
 {
     linkProfile.NavigateUrl = "/" + Account.GetAccountByID(blog.AccountID).Username;
     lblTitle.Text = blog.Title;
     lblPost.Text = blog.Post;
     imgAvatar.ImageUrl += "?AccountID=" + blog.AccountID.ToString();
     lblCreated.Text = blog.CreateDate.ToString("dd-MM-yyyy lúc HH:mm");
     //lblUpdated.Text = blog.UpdateDate.ToString("dd-MM-yyyy lúc HH:mm");
     comments.SystemObjectRecordID = blog.BlogID;
     blogID = blog.BlogID.ToString();
 }
Esempio n. 6
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Blog blog = new Blog();
     if (litBlogID.Text != "")
         blog.BlogID = Convert.ToInt64(litBlogID.Text);
     blog.IsPublished = chkIsPublished.Checked;
     blog.PageName = txtPageName.Text;
     blog.Post = txtMessage.Value;
     blog.Subject = txtSubject.Text;
     blog.Title = txtTitle.Text;
     _presenter.SavePost(blog);
     
     _redirector.GotoMyBlog(_webContext.Username,blog.PageName);
 }
Esempio n. 7
0
 public void SavePost(Blog blog)
 {
     bool result = Blog.CheckPageNameIsUnique(blog);
     if (result)
     {
         blog.AccountID = _webContext.CurrentUser.AccountID;
         Blog.SaveBlog(blog);
         _alertService.AddNewBlogPostAlert(blog);
     }
     else
     {
         _view.ShowError("The page name you have chosen is in use.  Please choose a different page name!");
     }
 }
Esempio n. 8
0
 public static Int64 SaveBlog(Blog blog)
 {
     blog = CleanPageName(blog);
     string post = blog.Post.Replace("<body>", "").Replace("<br /></body>", "").Replace("<html>", "")
         .Replace("</html>", "").Replace("<head>", "").Replace("</head>", "");
     blog.Post = post;
         if (blog.BlogID > 0)
         {
             blog.UpdateDate = DateTime.Now;
         }
         else
         {
             blog.CreateDate = DateTime.Now;
             blog.UpdateDate = DateTime.Now;
         }
         Blog.Add(blog);
     return blog.BlogID;
 }
Esempio n. 9
0
 private static Blog CleanPageName(Blog blog)
 {
     blog.PageName = blog.PageName.Replace(" ", "-").Replace("!", "")
         .Replace("&", "").Replace("?", "").Replace(",", "");
     return blog;
 }
Esempio n. 10
0
 public static void DeleteBlog(Blog blog)
 {
     Blog.Delete(blog.BlogID);
 }