Wrox Programmer Forums
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2006, 12:44 AM
Registered User
 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


 
Old August 14th, 2006, 12:49 AM
Registered User
 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old August 14th, 2006, 09:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please report this here:

http://www.wrox.com/WileyCDA/WroxTit...ew_errata.html

Click on the link for the "errata form".

Thanks,
Eric






Similar Threads
Thread Thread Starter Forum Replies Last Post
HEADS-UP: Error in Article class Lee Dumond BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 May 1st, 2008 11:28 PM
Most Rated Article tectrix BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 11 March 22nd, 2008 08:15 AM
Ask a article about ASP.NET 2.0 stonefang Classic ASP Professional 0 May 18th, 2007 12:20 AM
An Article- Inheritance in O/R Mapping sarosh SQL Language 0 January 10th, 2007 05:38 AM
An Article - Inheritance in O/R Mapping sarosh General .NET 0 May 16th, 2006 02:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.