public IEnumerable<Product> getProduct(IEnumerable<ProductModel> data)
        {
            var list = new List<Product>();
            if (data.Count() > 0)
            {
                foreach (var model in data)
                {
                    var prod = new Product();

                    if (model != null)
                    {
                        prod.CategoryId = model.CategoryId;
                        prod.Discontinued = model.Discontinued;
                        prod.Name = model.Name;
                        prod.ProductCategory = getCategory(model.ProductCategory);
                        prod.ProductId = model.ProductId;
                        prod.ProductSupplier = getSupplier(model.ProductSupplier);
                        prod.QuantityPerUnit = model.QuantityPerUnit;
                        prod.ReorderLevel = model.ReorderLevel;
                        prod.SupplierId = model.SupplierId;
                        prod.UnitPrice = model.UnitPrice;
                        prod.UnitsInStock = model.UnitsInStock;
                        prod.UnitsOnOrder = model.UnitsOnOrder;
                    }
                    list.Add(prod);
                }
            }
            return list.AsEnumerable();
        }
 public void SaveProduct(Product p)
 {
     using(var db = new DatabaseContext())
     {
         var id = db.Products.Max(a => a.ProductId);
         id++;
         p.ProductId = id;
         db.Insert(p);
     }
 }
        public Product getProduct(ProductModel model)
        {
            var prod = new Product();

            if (model != null)
            {
                prod.CategoryId = model.CategoryId;
                prod.Discontinued = model.Discontinued;
                prod.Name = model.Name;
                prod.ProductCategory = getCategory(model.ProductCategory);
                prod.ProductId = model.ProductId;
                prod.ProductSupplier = getSupplier(model.ProductSupplier);
                prod.QuantityPerUnit = model.QuantityPerUnit;
                prod.ReorderLevel = model.ReorderLevel;
                prod.SupplierId = model.SupplierId;
                prod.UnitPrice = model.UnitPrice;
                prod.UnitsInStock = model.UnitsInStock;
                prod.UnitsOnOrder = model.UnitsOnOrder;
            }

            return prod;
        }