//private List<UsersCustomModel> GetUserCustom(List<Users> users)
        //{
        //    List<UsersCustomModel> lstUsers = new List<UsersCustomModel>();
        //    lstUsers = (from y in users
        //                select new UsersCustomModel
        //                {
        //                    CurrentUser = y,
        //                    UserID = y.UserID,
        //                    CountryID = y.CountryID,
        //                    StateID = y.StateID,
        //                    CityID = y.CityID,
        //                    UserGroup = y.UserGroup,
        //                    UserName = y.UserName,
        //                    FirstName = y.FirstName,
        //                    LastName = y.LastName,
        //                    Answer = y.Answer,
        //                    Password = y.Password,
        //                    Address = y.Address,
        //                    Email = y.Email,
        //                    Phone = y.Phone,
        //                    HomePhone = y.HomePhone,
        //                    AdminUser = y.AdminUser,
        //                    IsActive = y.IsActive,
        //                    FailedLoginAttempts = y.FailedLoginAttempts,
        //                    IsDeleted = y.IsDeleted,
        //                    RoleName = GetRoleName(y.UserID),
        //                }).ToList();
        //    return lstUsers;

        //}

        /// <summary>
        /// Gets the name of the role.
        /// </summary>
        /// <param name="userID">The user identifier.</param>
        /// <returns></returns>
        private string GetRoleName(int userID)
        {
            string      RoleName       = string.Empty;
            UserRoleBal objUserRoleBal = new UserRoleBal();
            RoleBal     objRolBal      = new RoleBal();
            var         userRoles      = objUserRoleBal.GetUserRolesByUserId(userID);

            if (userRoles.Count > 0)
            {
                var firstUserRole = userRoles.FirstOrDefault();
                RoleName = objRolBal.GetRoleById(firstUserRole.RoleID).RoleName;
            }
            return(RoleName);
        }
        /// <summary>
        /// Gets the role identifier.
        /// </summary>
        /// <param name="userID">The user identifier.</param>
        /// <returns></returns>
        private int GetRoleId(int userID)
        {
            int         RoleId         = 0;
            UserRoleBal objUserRoleBal = new UserRoleBal();
            RoleBal     objRolBal      = new RoleBal();
            var         userRoles      = objUserRoleBal.GetUserRolesByUserId(userID);

            if (userRoles.Count > 0)
            {
                var firstUserRole = userRoles.FirstOrDefault();
                RoleId = objRolBal.GetRoleById(firstUserRole.RoleID).RoleID;
            }
            return(RoleId);
        }
        /// <summary>
        /// Gets the user roles.
        /// </summary>
        /// <param name="userid">The userid.</param>
        /// <returns></returns>
        private List <RoleSelectionCustomModel> GetUserRoles(int userid)
        {
            var userroleList = new List <RoleSelectionCustomModel>();
            var userroleBal  = new UserRoleBal();
            var roleBal      = new RoleBal();
            var facilityRole = new FacilityRoleBal();
            var facility     = new FacilityBal();
            var roles        = userroleBal.GetUserRolesByUserId(userid);

            foreach (var role in roles)
            {
                var roleFacilityIds = facilityRole.GetFacilityRolesByRoleId(role.RoleID);
                userroleList.AddRange(roleFacilityIds.Select(rolefacility => new RoleSelectionCustomModel
                {
                    RoleId       = role.RoleID,
                    RoleName     = roleBal.GetRoleNameById(role.RoleID),
                    FacilityName = facility.GetFacilityNameById(rolefacility.FacilityId),
                    FacilityId   = rolefacility.FacilityId,
                    CorporateId  = rolefacility.CorporateId
                }));
            }
            return(userroleList);
        }