Пример #1
0
        public Product AddProduct(Product product)
        {
            product.Id         = Guid.NewGuid();
            product.AuctionEnd = DateTime.UtcNow.AddMinutes(auctionOptions.DurationMinutes);
            databaseAdapter.AddProduct(product);

            return(product);
        }
        private void AddProduct(Product product)
        {
            try
            {
                _databaseAdapter.AddProduct(product);

                _products[product.Name] = product;
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Failed to add new product, name = {product.Name}");
            }
        }
        private void AddProduct(Product product)
        {
            try
            {
                _databaseAdapter.AddProduct(product);
                lock (_productsLock)
                {
                    _products.Add(product);
                }

                lock (_dictionaryLock)
                {
                    _productSensorsDictionary[product.Name] = new List <SensorInfo>();
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Failed to add new product, name = {product.Name}");
            }
        }