public async Task Edit(RoleEditUICommand command)
        {
            var role = await _roleRepository.Get(command.Id);

            if (role.IsDeleted)
            {
                throw new LogicServiceException(ErrorMessage.RoleIsDeleted);
            }
            if (_roleRepository.GetAll().Any(x => x.Name == command.Role.Name && x.Name != role.Name && !x.IsDeleted))
            {
                throw new LogicServiceException(ErrorMessage.RoleNameIsExisted);
            }

            role.Edit(command.Role.Name, command.Role.Memo, _userAuthenticationManager.CurrentUser.UserId,
                      _timeSource.GetCurrentTime());

            using var unitOfWork = _unitOfWorkFactory.GetCurrentUnitOfWork();
            _roleRepository.Edit(role);
            await unitOfWork.Commit();
        }
Exemplo n.º 2
0
 public async Task Put(Guid id, [FromBody] RoleEditUICommand command)
 {
     command.Id = id;
     await _roleLogicService.Edit(command);
 }