public async Task Handle(RoomCreatedEvent notification, CancellationToken cancellationToken) { if (!notification.CreateDefaultItemGroup) { return; } var command = new CreateRoomItemGroupCommand( id: await _idGenerator.GenerateAsync().ConfigureAwait(false), roomId: notification.Id, userId: notification.CreatedBy, name: "tea"); await _mediator.Send(command, CancellationToken.None).ConfigureAwait(false); //create some options foreach (var name in DefaultItemNames) { var optionCommand = new CreateOptionCommand( id: await _idGenerator.GenerateAsync().ConfigureAwait(false), userId: notification.CreatedBy, groupId: command.Id, name: name); await _mediator.Send(optionCommand, CancellationToken.None).ConfigureAwait(false); } }
public async Task <ICommandResult> AddGroup(string name) { var context = await GetContextAsync().ConfigureAwait(false); var command = new CreateRoomItemGroupCommand( id: await _idGenerator.GenerateAsync().ConfigureAwait(false), roomId: context.Room.Id, name: name, userId: context.User.Id ); await _mediator.Send(command).ConfigureAwait(false); return(Response(ResponseStrings.GroupAdded(name), ResponseType.User)); }