|
|
 |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0  | This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

August 14th, 2006, 01:44 AM
|
|
Registered User
|
|
Join Date: May 2004
Location: , , USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error in BLL.Article.Article.cs
I believe there is an error in the code in the Article.cs file in the BLL layer for the GetArticleCount(bool publishedOnly) method. The original method reads:
Code:
/// <summary>
/// Returns the number of total published articles
/// </summary>
public static int GetArticleCount(bool publishedOnly)
{
if (publishedOnly)
return GetArticleCount();
int articleCount = 0;
string key = "Articles_ArticleCount_" + publishedOnly.ToString();
if (BaseArticle.Settings.EnableCaching && BizObject.Cache[key] != null)
{
articleCount = (int)BizObject.Cache[key];
}
else
{
articleCount = SiteProvider.Articles.GetPublishedArticleCount(DateTime.Now);
BaseArticle.CacheData(key, articleCount);
}
return articleCount;
}
The problem I'm having is that when I pass in true to get the count for only published articles, its calling GetArticleCount, which returns the total number of articles, regardless of whether the article is published or not. If you pass in false, it does the exact opposite. I believe the code should read:
Code:
/// <summary>
/// Returns the number of total published articles
/// </summary>
public static int GetArticleCount(bool publishedOnly)
{
if (!publishedOnly)
return GetArticleCount();
int articleCount = 0;
string key = "Articles_ArticleCount_" + publishedOnly.ToString();
if (BaseArticle.Settings.EnableCaching && BizObject.Cache[key] != null)
{
articleCount = (int)BizObject.Cache[key];
}
else
{
articleCount = SiteProvider.Articles.GetPublishedArticleCount(DateTime.Now);
BaseArticle.CacheData(key, articleCount);
}
return articleCount;
}
The only change was made to the first if statement in the method. I simply inserted the NOT symbol to get the expected behavior.
Marco, can you verify that what I'm assuming is correct? Thanks and your book is awesome. Great job!
Douglas Rohm
|

August 14th, 2006, 01:49 AM
|
|
Registered User
|
|
Join Date: May 2004
Location: , , USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I also just verified the GetArticleCount(bool publishedOnly, int categoryID) method. Its using the logic I assumed in my previous post, confirming the error.
Code:
/// <summary>
/// Returns the number of total published articles for the specified category
/// </summary>
public static int GetArticleCount(bool publishedOnly, int categoryID)
{
if (!publishedOnly)
return GetArticleCount(categoryID);
if (categoryID <= 0)
return GetArticleCount(publishedOnly);
int articleCount = 0;
string key = "Articles_ArticleCount_" + publishedOnly.ToString() + "_" + categoryID.ToString();
if (BaseArticle.Settings.EnableCaching && BizObject.Cache[key] != null)
{
articleCount = (int)BizObject.Cache[key];
}
else
{
articleCount = SiteProvider.Articles.GetPublishedArticleCount(categoryID, DateTime.Now);
BaseArticle.CacheData(key, articleCount);
}
return articleCount;
}
Hope this helps.
Doug
|

August 14th, 2006, 10:56 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Atlanta, Georgia, USA.
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please report this here:
http://www.wrox.com/WileyCDA/WroxTit...ew_errata.html
Click on the link for the "errata form".
Thanks,
Eric
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |