public bool AddArticle(string login, string password, string blogname, Article article) { BusinessManagement.User user = new User(login); if (!user.Exists || !user.IsPasswordValid(password)) return false; BusinessManagement.Blog blog = new Blog(login, blogname); if (!blog.Exists) return false; BusinessManagement.Article.Create(blog.Id, article.MediaUrl, (long) ConvertToMediaType(article.MediaType), article.Text, TagsAsString(article.Tags)); return true; }
public bool DeleteArticle(string login, string password, string blogname, long articleId) { BusinessManagement.User user = new User(login); if (!user.Exists || !user.IsPasswordValid(password)) return false; Blog blog = new Blog(login, blogname); BusinessManagement.Article art = new BusinessManagement.Article(); DataAccess.T_Article article = BusinessManagement.Article.Get(articleId); if (!blog.Exists || article == null || article.BlogId != blog.Id) return false; art.Delete(articleId); return true; }
public List<Article> GetArticlesFromBlog(string blogOwner, string blogName) { List<Article> articles = new List<Article>(); Blog blog = new Blog(blogOwner, blogName); BusinessManagement.Article art = new BusinessManagement.Article(); if (!blog.Exists) return articles; blog.GetArticles().ForEach(item => { Dbo.Article dboArt = BusinessManagement.Article.GetArticleDbo(item.Id); articles.Add(ConvertToWebArticle(dboArt)); }); return articles; }
public Article GetArticleFromBlog(string blogOwner, string blogName, long articleId) { Blog blog = new Blog(blogOwner, blogName); if (!blog.Exists) return null; List<DataAccess.T_Article> articles = blog.GetArticles(); foreach (DataAccess.T_Article art in articles) { if (art.Id != articleId || blog.Id != art.BlogId) continue; return ConvertToWebArticle(BusinessManagement.Article.GetArticleDbo(art.Id)); }; return null; }
private void TestBlog(long blogId) { Blog blog = new Blog(); T_User user = blog.GetAuthor(blogId); if (!User.Identity.IsAuthenticated || User.Identity.Name != user.Login) throw new Exception("The user isn't the author of the blog, or the blog doesn't exist."); //RedirectToAction("Blog", "User"); }