Ejemplo n.º 1
0
        /// <summary>
        /// Find users by name.
        /// </summary>
        /// <param name="usernameToMatch">The username to match.</param>
        /// <param name="pageIndex">The page index.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="totalRecords">Total number of records.</param>
        /// <returns>The membership user collection.</returns>
        public System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            System.Web.Security.MembershipUserCollection                  memShipUsers = new System.Web.Security.MembershipUserCollection();
            Nequeo.DataAccess.ApplicationLogin.Data.Extension.User        user         = new Nequeo.DataAccess.ApplicationLogin.Data.Extension.User();
            Nequeo.DataAccess.ApplicationLogin.Data.Extension.UserAddress userAddress  = new Nequeo.DataAccess.ApplicationLogin.Data.Extension.UserAddress();

            // Get all the users for the match.
            long usersMatched = user.Select.
                                GetRecordCount(
                u =>
                (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.LoginUsername, ("%" + usernameToMatch + "%")))
                );

            // Get the total number of uses.
            totalRecords = Int32.Parse(usersMatched.ToString());
            int      skipNumber  = (pageIndex * pageSize);
            DateTime createdDate = DateTime.Now;

            // Get the current set on data.
            IQueryable <Data.User> users = user.Select.QueryableProvider().
                                           Where(u =>
                                                 (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.LoginUsername, ("%" + usernameToMatch + "%")))).
                                           OrderBy(u => u.UserID).
                                           Take(pageSize).
                                           Skip(skipNumber);

            // For each user found.
            foreach (Data.User item in users)
            {
                // Get the current users address details
                Data.UserAddress address = userAddress.Select.SelectDataEntity(u => u.UserAddressID == item.UserAddressID);

                // Create the membership user.
                System.Web.Security.MembershipUser memShipUser =
                    new System.Web.Security.MembershipUser(
                        ProviderName,
                        item.LoginUsername,
                        item.UserID,
                        address.EmailAddress,
                        "",
                        item.Comments,
                        true,
                        item.UserSuspended,
                        createdDate,
                        createdDate,
                        createdDate,
                        createdDate,
                        createdDate);

                // Add the user to the collection.
                memShipUsers.Add(memShipUser);
            }

            // Return the collection of membership users.
            return(memShipUsers);
        }
Ejemplo n.º 2
0
        public List <OwnerPresentationStub> MapListUsername(System.Web.Security.MembershipUserCollection dbItems)
        {
            List <OwnerPresentationStub> retList = new List <OwnerPresentationStub>();

            foreach (System.Web.Security.MembershipUser dbItem in dbItems)
            {
                retList.Add(new OwnerPresentationStub(dbItem));
            }

            return(retList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Find users by name.
        /// </summary>
        /// <param name="usernameToMatch">The username to match.</param>
        /// <param name="pageIndex">The page index.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="totalRecords">Total number of records.</param>
        /// <returns>The membership user collection.</returns>
        public System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            System.Web.Security.MembershipUserCollection           memShipUsers = new System.Web.Security.MembershipUserCollection();
            Nequeo.DataAccess.CloudInteraction.Data.Extension.User user         = new Nequeo.DataAccess.CloudInteraction.Data.Extension.User();

            // Get all the users for the match.
            long usersMatched = user.Select.
                                GetRecordCount(
                u =>
                (u.ApplicationName == ApplicationName) &&
                (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.Username, ("%" + usernameToMatch + "%")))
                );

            // Get the total number of uses.
            totalRecords = Int32.Parse(usersMatched.ToString());
            int skipNumber = (pageIndex * pageSize);

            // Get the current set on data.
            IQueryable <Data.User> users = user.Select.QueryableProvider().
                                           Where(u =>
                                                 (u.ApplicationName == ApplicationName) &&
                                                 (Nequeo.Data.TypeExtenders.SqlQueryMethods.Like(u.Username, ("%" + usernameToMatch + "%")))).
                                           OrderBy(u => u.Username).
                                           Take(pageSize).
                                           Skip(skipNumber);

            // For each user found.
            foreach (Data.User item in users)
            {
                // Create the membership user.
                System.Web.Security.MembershipUser memShipUser =
                    new System.Web.Security.MembershipUser(
                        ProviderName,
                        item.Username,
                        item.UserID,
                        item.Email,
                        item.PasswordQuestion,
                        item.Comments,
                        item.IsApproved,
                        item.UserSuspended,
                        item.CreationDate,
                        item.LastLoginDate,
                        item.LastActivityDate,
                        item.LastPasswordChangedDate,
                        item.UserSuspendedDate);

                // Add the user to the collection.
                memShipUsers.Add(memShipUser);
            }

            // Return the collection of membership users.
            return(memShipUsers);
        }
Ejemplo n.º 4
0
 public override System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     System.Web.Security.MembershipUserCollection list = new System.Web.Security.MembershipUserCollection();
     using (SqlNullDataReader reader = SqlHelper.ExecuteReader(_connectionString, "dbo.lg_Users_FindUsersByName",
                                                               SqlHelper.CreateInputParam("@UserName", SqlDbType.NVarChar, usernameToMatch)))
     {
         while (reader.Read())
         {
             list.Add(this.GetUserFromReader(reader));
         }
     }
     totalRecords = list.Count;
     return(list);
 }
Ejemplo n.º 5
0
 public override System.Web.Security.MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     System.Web.Security.MembershipUserCollection list = new System.Web.Security.MembershipUserCollection();
     using (SqlNullDataReader reader = SqlHelper.ExecuteReader(_connectionString, "dbo.lg_Users_GetAll",
                                                               SqlHelper.CreateInputParam("@StartRowIndex", SqlDbType.Int, pageIndex),
                                                               SqlHelper.CreateInputParam("@MaxRows", SqlDbType.Int, pageSize)))
     {
         while (reader.Read())
         {
             list.Add(this.GetUserFromReader(reader));
         }
     }
     totalRecords = list.Count;
     return(list);
 }
Ejemplo n.º 6
0
        private System.Web.Security.MembershipUserCollection ToMembershipUserCollection(IEnumerable <Models.User> users)
        {
            var mUsers = users.Select(user =>
                                      new System.Web.Security.MembershipUser(
                                          membershipName ?? Name,
                                          user.UserName,
                                          user.Id,
                                          user.Email,
                                          null,
                                          null,
                                          true,
                                          false,
                                          user.CreatedOn,
                                          System.DateTime.MinValue,
                                          System.DateTime.MinValue,
                                          System.DateTime.MinValue,
                                          System.DateTime.MinValue)).ToList();

            var collection = new System.Web.Security.MembershipUserCollection();

            mUsers.ForEach(collection.Add);

            return(collection);
        }
Ejemplo n.º 7
0
        private System.Web.Security.MembershipUserCollection ToMembershipUserCollection(IEnumerable<Models.User> users)
        {
            var mUsers = users.Select(user =>
                new System.Web.Security.MembershipUser(
                    membershipName ?? Name,
                    user.UserName,
                    user.Id,
                    user.Email,
                    null,
                    null,
                    true,
                    false,
                    user.CreatedOn,
                    System.DateTime.MinValue,
                    System.DateTime.MinValue,
                    System.DateTime.MinValue,
                    System.DateTime.MinValue)).ToList();

            var collection = new System.Web.Security.MembershipUserCollection();
            mUsers.ForEach(collection.Add);

            return collection;
        }
Ejemplo n.º 8
0
 public override System.Web.Security.MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     var users = Provider.GetAllUsers(pageIndex, pageSize, out totalRecords);
     System.Web.Security.MembershipUserCollection collection = new System.Web.Security.MembershipUserCollection();
     users.ForEach(u => collection.Add(MembershipUser.NewMembershipUser(u, Provider)));
     return collection;
 }
Ejemplo n.º 9
0
 public override System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     var users = Provider.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords);
     System.Web.Security.MembershipUserCollection collection = new System.Web.Security.MembershipUserCollection();
     users.ForEach(u => collection.Add(MembershipUser.NewMembershipUser(u, Provider)));
     return collection;
 }