Ejemplo n.º 1
0
        public override async Task <UpdateLineNameCommand> HandleAsync(UpdateLineNameCommand command, CancellationToken cancellationToken = new CancellationToken())
        {
            using (var uow = _contextFactory.Create())
            {
                var repository = new ShippingLineRepositoryAsync(uow);
                var line       = await repository.GetAsync(command.LineId);

                if (line == null)
                {
                    throw new NotFoundException($"Could not find a line with the Id: {command.LineId}");
                }

                line.LineName = command.LineName;

                await repository.UpdateAsync(line);

                await _commandProcessor.PostAsync(new LineNameUpdatedEvent(line.Id, line.LineName, line.Version));
            }
            return(await base.HandleAsync(command, cancellationToken));
        }