ToUser() public static method

Intentionally doesn't populate the User.Password property (as this is only ever stored).
public static ToUser ( UserEntity entity ) : User
entity UserEntity
return User
        public User GetUserById(Guid id, bool?isActivated = null)
        {
            UserEntity entity;

            if (isActivated.HasValue)
            {
                entity = Users.FirstOrDefault(x => x.Id == id && x.IsActivated == isActivated);
            }
            else
            {
                entity = Users.FirstOrDefault(x => x.Id == id);
            }

            return(FromEntity.ToUser(entity));
        }
        public User GetUserByEmail(string email, bool?isActivated = null)
        {
            UserEntity entity;

            if (isActivated.HasValue)
            {
                entity = Users.FirstOrDefault(x => x.Email == email && x.IsActivated == isActivated);
            }
            else
            {
                entity = Users.FirstOrDefault(x => x.Email == email);
            }

            return(FromEntity.ToUser(entity));
        }
        public User SaveOrUpdateUser(User user)
        {
            UserEntity entity = UnitOfWork.FindById <UserEntity>(user.Id);

            if (entity == null)
            {
                // Turn the domain object into a database entity
                entity = new UserEntity();
                ToEntity.FromUser(user, entity);
                UnitOfWork.Add(entity);
                UnitOfWork.SaveChanges();

                user = FromEntity.ToUser(entity);
            }
            else
            {
                ToEntity.FromUser(user, entity);
                UnitOfWork.SaveChanges();
            }

            return(user);
        }
        public User GetUserByUsernameOrEmail(string username, string email)
        {
            UserEntity entity = Users.FirstOrDefault(x => x.Username == username || x.Email == email);

            return(FromEntity.ToUser(entity));
        }
        public User GetUserByUsername(string username)
        {
            UserEntity entity = Users.FirstOrDefault(x => x.Username == username);

            return(FromEntity.ToUser(entity));
        }
        public User GetUserByPasswordResetKey(string key)
        {
            UserEntity entity = Users.FirstOrDefault(x => x.PasswordResetKey == key);

            return(FromEntity.ToUser(entity));
        }
        public User GetEditorById(Guid id)
        {
            UserEntity entity = Users.FirstOrDefault(x => x.Id == id && x.IsEditor);

            return(FromEntity.ToUser(entity));
        }
        public User GetUserByActivationKey(string key)
        {
            UserEntity entity = Users.FirstOrDefault(x => x.ActivationKey == key && x.IsActivated == false);

            return(FromEntity.ToUser(entity));
        }
Beispiel #9
0
        public User GetUserByUsername(Guid id)
        {
            UserEntity entity = Users.FirstOrDefault(x => x.Id == id);

            return(FromEntity.ToUser(entity));
        }