示例#1
0
        public static User FromDbEntity(SqlEntity.User sqlUser)
        {
            if (sqlUser == null)
            {
                return(null);
            }

            var db = new ApplicationDomainContext();

            var securityQuestion = SecurityQuestion.FromDbEntity(db.Select <SqlEntity.SecurityQuestion>()
                                                                 .First(q => q.Id == sqlUser.SecurityQuestion));

            //Do not fill the password
            return(new User
            {
                Id = sqlUser.Id,
                Username = sqlUser.Username,
                Role = (UserRole)sqlUser.Role,
                FullName = sqlUser.FullName,
                IsActive = sqlUser.IsActive == 1,
                IsDeleted = sqlUser.IsDeleted == 1,
                SuspendFrom = sqlUser.SuspendFrom,
                SuspendTo = sqlUser.SuspendTo,
                Email = sqlUser.Email,
                PasswordExpiration = sqlUser.PasswordExpiration,
                SecurityQuestion = new SecurityQuestion
                {
                    Id = securityQuestion.Id,
                    Question = securityQuestion.Question,
                    Answer = sqlUser.SecurityAnswer
                },
                Address = sqlUser.Address,
                DateOfBirth = sqlUser.DateOfBirth
            });
        }
示例#2
0
        public void DeleteUserById(int userId)
        {
            var user = new Entities.User
            {
                Id        = userId,
                IsDeleted = 1
            };

            GetDbContext().Update(user, "isDeleted");
        }
示例#3
0
        public void EnableUserById(int userId)
        {
            var user = new Entities.User
            {
                Id       = userId,
                IsActive = 1
            };

            GetDbContext().Update(user, "isActive");
        }
        public static PasswordHistory FromDbEntity(SqlEntities.PasswordHistory passwordHistory, SqlEntities.User user, SqlEntities.SecurityQuestion securityQuestion)
        {
            if (passwordHistory == null)
            {
                return(null);
            }

            return(FromDbEntity(passwordHistory, User.FromDbEntity(user)));
        }