Ejemplo n.º 1
0
        public static UserStatisticsInfo PopulateUserStatistics(IDataRecord reader)
        {
            if (reader == null)
            {
                return(null);
            }
            UserStatisticsInfo info = new UserStatisticsInfo();

            if (reader["RegionId"] != DBNull.Value)
            {
                info.RegionId = (int)reader["RegionId"];
            }
            if (reader["Usercounts"] != DBNull.Value)
            {
                info.Usercounts = (int)reader["Usercounts"];
            }
            if (reader["AllUserCounts"] != DBNull.Value)
            {
                info.AllUserCounts = (int)reader["AllUserCounts"];
            }
            return(info);
        }
Ejemplo n.º 2
0
        public IList <UserStatisticsInfo> GetUserStatistics(Pagination page, out int totalRegionsUsers)
        {
            DbCommand sqlStringCommand      = this.database.GetSqlStringCommand("SELECT TopRegionId as RegionId,COUNT(UserId) as UserCounts,(select count(*) from aspnet_Members) as AllUserCounts FROM aspnet_Members  GROUP BY TopRegionId ");
            IList <UserStatisticsInfo> list = new List <UserStatisticsInfo>();

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                UserStatisticsInfo item = null;
                while (reader.Read())
                {
                    item = DataMapper.PopulateUserStatistics(reader);
                    list.Add(item);
                }
                if (item != null)
                {
                    totalRegionsUsers = int.Parse(item.AllUserCounts.ToString());
                    return(list);
                }
                totalRegionsUsers = 0;
            }
            return(list);
        }