[OutputCache(Duration = 14400)] //4 hours
        public JsonNetResult Overall()
        {
            var stats = new OverallStatistics {
                LastUpdated = DateTime.UtcNow
            };

            using (var conn = _dbService.GetConnection())
            {
                stats.TotalOrdersPlaced    = conn.Query <int>("select COUNT(*) from Orders").Single();
                stats.TotalOrdersCompleted = conn.Query <int>("select COUNT(*) from Orders where OrderStatusCodeId = 'CP'").Single();
                stats.TotalAmount          = string.Format("{0:C2}", conn.Query <decimal>("select SUM(Total) as OrderTotalSumCompleted from Orders").Single());
                var amount = conn.Query <decimal>("select SUM(Total) as OrderTotalSumCompleted from Orders where OrderStatusCodeId = 'CP' and Total < 100000000").Single();
                stats.TotalAmountCompleted = string.Format("{0:C2}", amount);


                stats.ShowFireworks = (amount > 100000000.0m && amount < 101000000.0m);

                stats.Attachments = conn.Query <int>("select COUNT(*) from Attachments").Single();
                stats.Accounts    = conn.Query <int>("select COUNT(distinct Account) from Splits").Single();

                stats.ActiveUsersInWorkgroups = conn.Query <int>("select COUNT( distinct UserId) from WorkgroupPermissions").Single();
                stats.Actions    = conn.Query <int>("select COUNT(*) from OrderTracking").Single();
                stats.Workgroups = conn.Query <int>("select count(*) from Workgroups where IsActive = 1").Single();

                stats.OrgsWithOrders     = conn.Query <int>("select COUNT(distinct OrganizationId) from Orders").Single();
                stats.OrgsWithWorkgroups = conn.Query <int>("select COUNT(distinct OrganizationId) from WorkgroupsXOrganizations").Single();
            }

            return(new JsonNetResult(stats));
        }
        public JsonNetResult Overall()
        {
            var stats = new OverallStatistics { LastUpdated = DateTime.UtcNow };

            using (var conn = _dbService.GetConnection())
            {
                stats.TotalOrdersPlaced = conn.Query<int>("select COUNT(*) from Orders").Single();
                stats.TotalOrdersCompleted = conn.Query<int>("select COUNT(*) from Orders where OrderStatusCodeId = 'CP'").Single();
                stats.TotalAmount = string.Format("{0:C2}", conn.Query<decimal>("select SUM(Total) as OrderTotalSumCompleted from Orders").Single());
                var amount = conn.Query<decimal>("select SUM(Total) as OrderTotalSumCompleted from Orders where OrderStatusCodeId = 'CP' and Total < 100000000").Single();
                stats.TotalAmountCompleted = string.Format("{0:C2}",amount);

                stats.ShowFireworks = ( amount > 100000000.0m && amount < 101000000.0m);

                stats.Attachments = conn.Query<int>("select COUNT(*) from Attachments").Single();
                stats.Accounts = conn.Query<int>("select COUNT(distinct Account) from Splits").Single();

                stats.ActiveUsersInWorkgroups = conn.Query<int>("select COUNT( distinct UserId) from WorkgroupPermissions").Single();
                stats.Actions = conn.Query<int>("select COUNT(*) from OrderTracking").Single();
                stats.Workgroups = conn.Query<int>("select count(*) from Workgroups where IsActive = 1").Single();

                stats.OrgsWithOrders = conn.Query<int>("select COUNT(distinct OrganizationId) from Orders").Single();
                stats.OrgsWithWorkgroups = conn.Query<int>("select COUNT(distinct OrganizationId) from WorkgroupsXOrganizations").Single();

            }

            return new JsonNetResult(stats);
        }