Пример #1
0
        public IViewTopUsers GetById(int id)
        {
            IViewTopUsers viewTopUsers = new ViewTopUsers();
            string        sqlCommand   = "viewTopUsersFind";

            using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand))
            {
                IDataQuery query = new DataQuery();
                query.Where = string.Format(" viewTopUsersId= {0} ", id);

                _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, query.From);
                _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, query.Where);
                _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, query.OrderBy);

                // Call the ExecuteReader method with the command.
                using (IDataReader reader = _dataBase.ExecuteReader(dbCmd))
                {
                    while (reader.Read())
                    {
                        viewTopUsers.ProfileId  = Convert.ToInt32(reader["profileId"].ToString());
                        viewTopUsers.UsuarioId  = Convert.ToInt32(reader["usuarioId"].ToString());
                        viewTopUsers.TotalVotes = Convert.ToInt32(reader["totalVotes"].ToString());
                        viewTopUsers.Name       = reader["name"].ToString();
                        viewTopUsers.Picture    = reader["picture"].ToString();
                        viewTopUsers.Gender     = reader["gender"].ToString();
                    }
                }
            }

            return(viewTopUsers);
        }
Пример #2
0
        public IList <IViewTopUsers> GetTop <IViewTopUsersQueryParams>(int top, IViewTopUsersQueryParams query)
        {
            _collection = new List <IViewTopUsers>();
            string sqlCommand = "viewTopUsersGetTop";

            using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand))
            {
                _dataBase.AddInParameter(dbCmd, "@topParam", DbType.Int32, top);
                _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, ((IDataQuery)query).From);
                _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, ((IDataQuery)query).Where);
                _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, ((IDataQuery)query).OrderBy);

                using (IDataReader reader = _dataBase.ExecuteReader(dbCmd))
                {
                    while (reader.Read())
                    {
                        IViewTopUsers viewTopUsers = new ViewTopUsers();

                        viewTopUsers.ProfileId  = Convert.ToInt32(reader["profileId"].ToString());
                        viewTopUsers.UsuarioId  = Convert.ToInt32(reader["usuarioId"].ToString());
                        viewTopUsers.TotalVotes = Convert.ToInt32(reader["totalVotes"].ToString());
                        viewTopUsers.Name       = reader["name"].ToString();
                        viewTopUsers.Picture    = reader["picture"].ToString();
                        viewTopUsers.Gender     = reader["gender"].ToString();
                        _collection.Add(viewTopUsers);
                    }
                }
            }

            return(_collection);
        }
Пример #3
0
        public IList <IViewTopUsers> Find <IViewTopUsersQueryParams>(IViewTopUsersQueryParams query)
        {
            _collection = new List <IViewTopUsers>();
            string sqlCommand = "viewTopUsersFind";

            // Create a suitable command type and add the required parameter.
            using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand))
            {
                _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, ((IDataQuery)query).From);
                _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, ((IDataQuery)query).Where);
                _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, ((IDataQuery)query).OrderBy);
                _dataBase.AddInParameter(dbCmd, "@pageNumber", DbType.String, ((IDataQuery)query).Page);
                _dataBase.AddInParameter(dbCmd, "@rowCount", DbType.String, ((IDataQuery)query).RowCount);

                // Call the ExecuteReader method with the command.
                using (IDataReader reader = _dataBase.ExecuteReader(dbCmd))
                {
                    while (reader.Read())
                    {
                        IViewTopUsers viewTopUsers = new ViewTopUsers();

                        viewTopUsers.ProfileId  = Convert.ToInt32(reader["profileId"].ToString());
                        viewTopUsers.TotalVotes = Convert.ToInt32(reader["totalVotes"].ToString());
                        viewTopUsers.Name       = reader["name"].ToString();
                        viewTopUsers.Picture    = reader["picture"].ToString();
                        _collection.Add(viewTopUsers);
                    }
                }
            }

            return(_collection);
        }