Пример #1
0
        private CategoryCount GetCategoryInfo(string userName)
        {
            var parameters = new List <SqlParameter>
            {
                new SqlParameter("username", userName)
            };

            var query = @"
                SELECT  Category AS [Category] ,
                        COUNT(*) AS [Tickets]
                FROM    dbo.Tickets
                WHERE   AssignedTo = @username
                GROUP BY Category 
            ";

            var categoryCount = new CategoryCount();

            var results = DoDatabaseQuery(query, parameters);

            while (results.Read())
            {
                if ((string)results["Category"] == "Hardware")
                {
                    categoryCount.Hardware = (int)results["Tickets"];
                }
                if ((string)results["Category"] == "Software")
                {
                    categoryCount.Software = (int)results["Tickets"];
                }
                if ((string)results["Category"] == "Network")
                {
                    categoryCount.Network = (int)results["Tickets"];
                }
            }
            results.Close();

            return(categoryCount);
        }
Пример #2
0
        private string SerializeCategories(CategoryCount categories)
        {
            var categoryCountInfo = "Hardware tickets: " + categories.Hardware + ", Network tickets: " + categories.Network + ", Software tickets: " + categories.Software;

            return(categoryCountInfo);
        }