Esempio n. 1
0
        protected override async Task <UpdateUserResponse> AssertForUpdateAction(UpdateUserRequest request)
        {
            var userToUpdate = await _userRepository.Get(request.Id);

            if (request.UserName != null)
            {
                userToUpdate.SetName(new Name(request.UserName));
            }
            if (request.Password != null)
            {
                userToUpdate.SetPassword(new Password(request.Password));
            }
            if (request.Roles != null)
            {
                userToUpdate.SetRoles(request.Roles.Select(role => new Role(new Name(role))));
            }

            await _userRepository.Update(userToUpdate);

            return(UpdateUserResponse.Success(userToUpdate, "User successfully updated."));
        }
Esempio n. 2
0
        protected override async Task <UpdateUserResponse> AssertForUpdateAction(UpdateUserRequest request)
        {
            var userToUpdate = await _userRepository.Get(request.Id);

            return(userToUpdate == null?UpdateUserResponse.UserNotFound(new[] { "User does not exist." }) : null);
        }
Esempio n. 3
0
 protected abstract Task <UpdateUserResponse> AssertForUpdateAction(UpdateUserRequest request);
Esempio n. 4
0
        /// <inheritdoc />
        public async Task <UpdateUserResponse> AssertForUpdate(UpdateUserRequest request)
        {
            var actionResult = await AssertForUpdateAction(request);

            return(actionResult ?? await Successor.AssertForUpdate(request));
        }