public async Task <StockResponse> PostStocks(Stock[] stocks) { if (stocks == null || stocks.Length < 1) { return new StockResponse { Status = ResponseStatus.Failure, Reason = "Stocks are empty" } } ; var itemNumbers = stocks.Select(s => s.ItemNumber); if (!itemNumbers.Any()) { return new StockResponse { Status = ResponseStatus.Failure, Reason = "Stock has no item numbers" } } ; foreach (var item in itemNumbers) { var exists = await _itemsRepository.CheckIfItemExists(item).ConfigureAwait(false); if (!exists) { return(new StockResponse { Status = ResponseStatus.Failure, Reason = $"Item {item} doesn't exist. Please add it in the items tab" }); } } await _stocksRepository.InsertStocks(stocks).ConfigureAwait(false); return(new StockResponse { Status = ResponseStatus.Success }); }