Service class that abstracts the interraction around the user entity with the data layer.
상속: BaseService
        public override string[] GetRolesForUser(string username)
        {
            UserService userService = new UserService();

            var user = userService.GetUser(username);

            return new[] {((UserType) user.UserTypeId).ToString()};
        }
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            UserService userService = new UserService();

            var user = userService.GetUsers().Where(x=>x.Username == username).FirstOrDefault();

            var membershipUser = GetUser(user.UserInfoId, userIsOnline);

            return membershipUser;
        }
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            UserService userService = new UserService();

            var user = userService.GetUser((int)providerUserKey);

            var membershipUser = new GameSchoolMembershipUser("GameSchoolMembershipProvider", user.Username, user.UserInfoId, user.Email, string.Empty,
                                                     string.Empty, true, false, user.CreateDateTime, DateTime.Now,
                                                     DateTime.Now, DateTime.Now, DateTime.Now, user.Fullname, user.UserInfoId, user.UserTypeId);

            return membershipUser;
        }
        public override bool IsUserInRole(string username, string roleName)
        {
            UserService userService = new UserService();

            var user = userService.GetUser(username);

            if (user != null)
            {
                if (user.UserTypeId == (int)UserTypeResolver.Get(roleName))
                { 
                    return true;
                }
            }
            return false;
        }
        public override bool ValidateUser(string username, string password)
        {
            UserService userService = new UserService();

            var request = HttpContext.Current.Request.UserHostAddress == "::1"
                              ? "localhost"
                              : HttpContext.Current.Request.UserHostAddress ?? string.Empty;

            var userInfo = userService.Login(username, password, request );

            if (userInfo != null)
            { 
                return true;
            }
            return false;
        }
예제 #6
0
 public void MyTestInitialize()
 {
     _mockRepository = MockRepository.GenerateMock<IGameSchoolEntities>();
     _userService = new UserService();
     _userService.SetDatasource(_mockRepository);
 }