public CreateStockReadModelCommandHandler(IStockDbContext stockDbContext, IStockUniqueChecker stockUniqueChecker)
 {
     _stockDbContext     = stockDbContext;
     _stockUniqueChecker = stockUniqueChecker;
 }
Exemplo n.º 2
0
        public static Stock Create(string productId, int availableStock, Guid stockActionId, DateTime lastStockOperationDate, IStockUniqueChecker stockUniqueChecker, CancellationToken cancellationToken)
        {
            var unique = stockUniqueChecker.CheckAsync(productId, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult();

            if (!unique)
            {
                throw new StockAlreadyExistException(productId);
            }

            Stock stock = new Stock(productId, availableStock, stockActionId, lastStockOperationDate);

            return(stock);
        }