public async Task Handle(OptionSold e, CancellationToken cancellationToken)
        {
            var o = await _storage.GetOwnedOption(e.AggregateId, e.UserId);

            if (o == null)
            {
                return;
            }

            var when   = e.When;
            var notes  = e.Notes;
            var ticker = o.State.Ticker;

            await CreateNote(e.UserId, when, notes, ticker);
        }
Ejemplo n.º 2
0
            public async Task <CommandResponse <OwnedOption> > Handle(Command cmd, CancellationToken cancellationToken)
            {
                var option = await _storage.GetOwnedOption(cmd.Id.Value, cmd.UserId);

                if (option == null)
                {
                    return(CommandResponse <OwnedOption> .Failed("Trying to expire not owned option"));
                }

                option.Expire(cmd.Assigned.Value);

                await _storage.Save(option, cmd.UserId);

                return(CommandResponse <OwnedOption> .Success(option));
            }
Ejemplo n.º 3
0
            public async Task <CommandResponse <OwnedOption> > Handle(Command cmd, CancellationToken cancellationToken)
            {
                var option = await _storage.GetOwnedOption(cmd.Id, cmd.UserId);

                if (option == null)
                {
                    return(CommandResponse <OwnedOption> .Failed("Trying to delete not owned option"));
                }

                option.Delete();

                await this._storage.Save(option, cmd.UserId);

                return(CommandResponse <OwnedOption> .Success(option));
            }