Kaffeplaneten.DAL.ProductDAL.add C# (CSharp) Method

add() public method

public add ( ProductModel productModel ) : bool
productModel Kaffeplaneten.Models.ProductModel
return bool
        public bool add(ProductModel productModel)
        {
            using (var db = new CustomerContext())
            {
                try
                {
                    var product = new Products();
                    product.category = productModel.category;
                    product.description = productModel.description;
                    product.imageURL = productModel.imageURL;
                    product.price = productModel.price;
                    product.productName = productModel.productName;
                    product.stock = productModel.stock;
                    db.Products.Add(product);
                    db.SaveChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    _logging.logToDatabase(ex);
                }
                return false;
            }
        }