예제 #1
0
        public void SaveProduct(ProductsModel model)
        {
            try
            {
                var product = new Products
                {
                    Discontinued    = model.Discontinued,
                    ProductName     = model.ProductName,
                    QuantityPerUnit = model.QuantityPerUnit,
                    ReorderLevel    = model.ReorderLevel,
                    UnitPrice       = model.UnitPrice,
                    UnitsInStock    = model.UnitsInStock,
                    UnitsOnOrder    = model.UnitsOnOrder,
                    CategoryId      = model.Category?.CategoryId,
                    SupplierId      = model.Supplier?.SupplierId
                };

                _productsRepository.Insert(product);
            }
            catch (Exception e)
            {
                Log.Error("Product service error!" + Environment.NewLine + $"{e}");
                throw;
            }
        }