public abstract int InsertArticle(ArticleDetails article);
/// <summary> /// Updates an article /// </summary> public override bool UpdateArticle(ArticleDetails article) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("wa_Articles_UpdateArticle", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ArticleID", SqlDbType.Int).Value = article.ID; cmd.Parameters.Add("@CategoryID", SqlDbType.Int).Value = article.CategoryID; cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = article.Title; cmd.Parameters.Add("@Abstract", SqlDbType.NVarChar).Value = article.Abstract; cmd.Parameters.Add("@Body", SqlDbType.NText).Value = article.Body; cmd.Parameters.Add("@Country", SqlDbType.NVarChar).Value = article.Country; cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = article.State; cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value = article.City; cmd.Parameters.Add("@ReleaseDate", SqlDbType.DateTime).Value = article.ReleaseDate; cmd.Parameters.Add("@ExpireDate", SqlDbType.DateTime).Value = article.ExpireDate; cmd.Parameters.Add("@Approved", SqlDbType.Bit).Value = article.Approved; cmd.Parameters.Add("@Listed", SqlDbType.Bit).Value = article.Listed; cmd.Parameters.Add("@CommentsEnabled", SqlDbType.Bit).Value = article.CommentsEnabled; cmd.Parameters.Add("@OnlyForMembers", SqlDbType.Bit).Value = article.OnlyForMembers; cmd.Parameters.Add("@BannerUrl", SqlDbType.NVarChar).Value = article.BannerUrl; cn.Open(); int ret = ExecuteNonQuery(cmd); return (ret == 1); } }
protected virtual ArticleDetails GetArticleFromReader(IDataReader reader, bool readBody) { ArticleDetails article = new ArticleDetails( (int)reader["ArticleID"], (DateTime)reader["AddedDate"], reader["AddedBy"].ToString(), (int)reader["CategoryID"], reader["CategoryTitle"].ToString(), reader["Title"].ToString(), reader["Abstract"].ToString(), (reader["BannerUrl"] == DBNull.Value ? "" : reader["BannerUrl"].ToString()), (int)reader["CommentsCount"], null, reader["Country"].ToString(), reader["State"].ToString(), reader["City"].ToString(), (reader["ReleaseDate"] == DBNull.Value ? DateTime.Now : (DateTime)reader["ReleaseDate"]), (reader["ExpireDate"] == DBNull.Value ? DateTime.MaxValue : (DateTime)reader["ExpireDate"]), (bool)reader["Approved"], (bool)reader["Listed"], (bool)reader["CommentsEnabled"], (bool)reader["OnlyForMembers"], (int)reader["ViewCount"], (int)reader["Votes"], (int)reader["TotalRating"]); if (readBody) article.Body = reader["Body"].ToString(); return article; }
public abstract bool UpdateArticle(ArticleDetails article);
/// <summary> /// Returns a Article object filled with the data taken from the input ArticleDetails /// </summary> private static Article GetArticleFromArticleDetails(ArticleDetails record) { if (record == null) return null; else { return new Article(record.ID, record.AddedDate, record.AddedBy, record.CategoryID, record.CategoryTitle, record.Title, record.Abstract, record.BannerUrl, record.CommentsCount, record.Body, record.Country, record.State, record.City, record.ReleaseDate, record.ExpireDate, record.Approved, record.Listed, record.CommentsEnabled, record.OnlyForMembers, record.ViewCount, record.Votes, record.TotalRating); } }
/// <summary> /// Updates an existing article /// </summary> public static bool UpdateArticle(int id, int categoryID, string title, string Abstract, string bannerUrl, string body, string country, string state, string city, DateTime releaseDate, DateTime expireDate, bool approved, bool listed, bool commentsEnabled, bool onlyForMembers) { title = BizObject.ConvertNullToEmptyString(title); Abstract = BizObject.ConvertNullToEmptyString(Abstract); body = BizObject.ConvertNullToEmptyString(body); country = BizObject.ConvertNullToEmptyString(country); state = BizObject.ConvertNullToEmptyString(state); city = BizObject.ConvertNullToEmptyString(city); bannerUrl = BizObject.ConvertNullToEmptyString(bannerUrl); if (releaseDate == DateTime.MinValue) releaseDate = DateTime.Now; if (expireDate == DateTime.MinValue) expireDate = DateTime.MaxValue; ArticleDetails record = new ArticleDetails(id, DateTime.Now, "", categoryID, "", title, Abstract, bannerUrl, 0, body, country, state, city, releaseDate, expireDate, approved, listed, commentsEnabled, onlyForMembers, 0, 0, 0); bool ret = SiteProvider.Articles.UpdateArticle(record); BizObject.PurgeCacheItems("articles_article_" + id.ToString()); BizObject.PurgeCacheItems("articles_articles"); return ret; }
/// <summary> /// Creates a new article /// </summary> public static int InsertArticle(int categoryID, string title, string Abstract, string bannerUrl, string body, string country, string state, string city, DateTime releaseDate, DateTime expireDate, bool approved, bool listed, bool commentsEnabled, bool onlyForMembers) { // ensure that the "approved" option is false if the current user is not // an administrator or a editor (it may be a contributor for example) bool canApprove = (BizObject.CurrentUser.IsInRole("Administrators") || BizObject.CurrentUser.IsInRole("Editors")); if (!canApprove) approved = false; title = BizObject.ConvertNullToEmptyString(title); Abstract = BizObject.ConvertNullToEmptyString(Abstract); body = BizObject.ConvertNullToEmptyString(body); country = BizObject.ConvertNullToEmptyString(country); state = BizObject.ConvertNullToEmptyString(state); city = BizObject.ConvertNullToEmptyString(city); bannerUrl = BizObject.ConvertNullToEmptyString(bannerUrl); if (releaseDate == DateTime.MinValue) releaseDate = DateTime.Now; if (expireDate == DateTime.MinValue) expireDate = DateTime.MaxValue; ArticleDetails record = new ArticleDetails(0, DateTime.Now, BizObject.CurrentUserName, categoryID, "", title, Abstract, bannerUrl, 0, body, country, state, city, releaseDate, expireDate, approved, listed, commentsEnabled, onlyForMembers, 0, 0, 0); int ret = SiteProvider.Articles.InsertArticle(record); BizObject.PurgeCacheItems("articles_articles"); return ret; }