public StockStatus CheckStock(IsInStock command) { var inventory = _inventoryContext.Inventory.FirstOrDefault(x => x.ProductId == command.ProductId); if (inventory == null || inventory.CalculateCurrentCount() < command.Count) { var product = _shopContext.Products.Select(x => new { x.Id, x.Name }) .FirstOrDefault(x => x.Id == command.ProductId); return(new StockStatus { IsStock = false, ProductName = product?.Name }); } return(new StockStatus { IsStock = true }); }
public StockStatus CheckStock(IsInStock command) { return(_inventoryQuery.CheckStock(command)); }