public List <UserListing> GetAll()
        {
            List <UserListing> users = new List <UserListing>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("UsersSelectAll", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        UserListing currentRow = new UserListing();
                        currentRow.UserId       = dr["Id"].ToString();
                        currentRow.LastName     = dr["LastName"].ToString();
                        currentRow.FirstName    = dr["FirstName"].ToString();
                        currentRow.Email        = dr["Email"].ToString();
                        currentRow.UserRoleName = dr["UserRoleName"].ToString();

                        users.Add(currentRow);
                    }
                }
            }
            return(users);
        }
예제 #2
0
        public static List<UserListing> GetAllUsers()
        {
            //DB Connection goes here

            List<UserListing> _article = new List<UserListing>();

            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = "GetAllUsers";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // DataSet that will hold the returned results
            DataSet commentaryDataSet = null;

            commentaryDataSet = db.ExecuteDataSet(dbCommand);

            // Note: connection was closed by ExecuteDataSet method call

            foreach (DataRow dr in commentaryDataSet.Tables[0].Rows)
            {
                 UserListing _portfoliolisting = new UserListing();
                _portfoliolisting.UserId = dr["UserId"].ToString();
                _portfoliolisting.IsPaidSubscriber = bool.Parse(dr["IsPaidSubscriber"].ToString());
                _portfoliolisting.RegistrationDate = DateTime.Parse(dr["RegistrationDate"].ToString());
                _portfoliolisting.FirstName = dr["FirstName"].ToString();
                _portfoliolisting.LastName = dr["FirstName"].ToString();
                _article.Add(_portfoliolisting);
            }

            return _article;
        }
예제 #3
0
        public UserListing GetListing()
        {
            var listing     = new UserListing();
            var users       = UserRepository.GetAll(UserEmail).Select(p => p).ToList();
            var rolesLookup = new Dictionary <string, string>();

            foreach (var user in users)
            {
                //var roles = userManager.GetRolesAsync(user).Result.ToArray();
                var roleIds = UserRoleDetail.GetAll().Where(r => r.UserId == user.Id).Select(r => r.RoleId).ToArray();
                var roles   = AnraRole.GetAll().Where(r => roleIds.Contains(r.RoleId)).Select(r => r.RoleName).ToArray();
                rolesLookup.Add(user.Id, string.Join(",", roles));
            }

            listing.Users = users.ToList().Adapt <List <User>, IEnumerable <UserListItem> >().ToList();

            foreach (var user in listing.Users)
            {
                user.RoleName = rolesLookup[user.Id];
                var org = OrganizationRepositoy.Find(user.OrganizationId);
                user.OrganizationName = org != null ? org.Name : "";
            }

            return(listing);
        }
예제 #4
0
        /// <summary>Gets the users.</summary>
        /// <param name="skip">The skip.</param>
        /// <param name="take">The take.</param>
        /// <returns>UserListing.</returns>
        public UserListing GetUsers(int skip = 0, int take = 10)
        {
            var obj = _dataService.GetSet <OmdleUser>()
                      .Skip(skip * take)
                      .Take(take)
                      .ToList();

            var list = new UserListing
            {
                Users      = obj,
                TotalCount = obj.Count()
            };

            return(list);
        }
예제 #5
0
        /// <summary>Gets the teachers.</summary>
        /// <param name="skip">The skip.</param>
        /// <param name="take">The take.</param>
        /// <returns>UserListing.</returns>
        public UserListing GetTeachers(int skip = 0, int take = 10)
        {
            var obj   = _dataService.GetSet <OmdleUser>().ToList();
            var model = obj
                        .Where(x => _userManager.IsInRoleAsync(x, "Teacher").Result)
                        .Skip(skip * take)
                        .Take(take)
                        .ToList();

            var list = new UserListing
            {
                Users      = model,
                TotalCount = model.Count()
            };

            return(list);
        }
예제 #6
0
 public UserListingViewModel(UserListing model)
 {
     TotalCount = model.TotalCount;
     Users      = model.Users.Select(x => new UserViewModel(x)).ToList();
 }
예제 #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filterData"></param>
        /// <returns></returns>
        public static List<UserListing> GetUserFilterData(string filterData)
        {
            //DB Connection goes here

            List<UserListing> _article = new List<UserListing>();

            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = "GetAllUsers";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Retrieve products from the specified category.
            //db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, Category);

            // DataSet that will hold the returned results
            DataSet commentaryDataSet = null;

            commentaryDataSet = db.ExecuteDataSet(dbCommand);

            DataRow[] dataRow;

            dataRow = commentaryDataSet.Tables[0].Select("UserId LIKE '%" + filterData + "%'");

            // Note: connection was closed by ExecuteDataSet method call

            foreach (DataRow dr in dataRow)
            {
                UserListing _userlisting = new UserListing();
                 _userlisting.UserId = dr["UserId"].ToString();
                _userlisting.IsPaidSubscriber = bool.Parse(dr["IsPaidSubscriber"].ToString());
                _userlisting.RegistrationDate = DateTime.Parse(dr["RegistrationDate"].ToString());
                _userlisting.FirstName = dr["FirstName"].ToString();
                _userlisting.LastName = dr["LastName"].ToString();
                 _article.Add(_userlisting);
            }

            return _article;
        }