public async Task HandleAsync(CreateGroupCommand command) { var groupId = GroupId.From(command.GroupId); if (await _groupRepository.ExistsAsync(groupId)) { throw new GroupAlreadyExistsException(groupId); } var me = await _client.GetAsync <UserDto>("/identity/me", new MeQuery(command.UserId)); var avatar = await GetAvatar(me.Avatar); var group = Domain.Entities.Group.Create(groupId, GroupName.Create(command.GroupName), UserId.From(command.UserId), MemberName.Create(me.Nickname), avatar, _clock); await _groupRepository.AddAsync(group); }
public async Task HandleAsync(RenameGroupCommand command) { var group = await _groupRepository.GetAsync(GroupId.From(command.GroupId)) ?? throw new GroupNotFoundException(GroupId.From(command.GroupId)); group.Rename(UserId.From(command.UserId), GroupName.Create(command.Name)); }