public virtual int StoreProduct(Product product)
        {
            product.ProductID = random.Next(0, 10000);
            Cache.Add(product.ProductID, product);

            return product.ProductID;
        }
 public void DeleteProduct(int productId)
 {
     using (SqlServerProductsDb Db = new SqlServerProductsDb(ConnectionString))
     {
         var prod = new Product() { ProductID = productId };
         Db.Products.Attach(prod);
         Db.Products.Remove(prod);
         Db.SaveChanges();
     }
 }
Esempio n. 3
0
        public static ProductDto DtoFromProduct(Product product)
        {
            if (product == null) return null;

            return new ProductDto()
            {
                Name = product.Name,
                Description = product.Description,
                Inventory = product.Inventory,
                ProductID = product.ProductID,
                PurchasePrice = product.PurchasePrice,
                SalePrice = product.SalePrice,
                UnitQuantity = product.UnitQuantity
            };
        }
Esempio n. 4
0
 public int StoreProduct(Product product)
 {
     var products = AllProducts();
     product.ProductID = DateTime.Now.Millisecond;
     products.Add(product);
     using(FileStream stream = File.Open(FilePath,FileMode.Create))
     {
         Serializer.Serialize(stream, products);
     }
     return product.ProductID;
 }
 public int StoreProduct(Product product)
 {
     using (SqlServerProductsDb Db = new SqlServerProductsDb(ConnectionString))
     {
         Db.Products.Add(product);
         Db.SaveChanges();
     }
     return product.ProductID;
 }
Esempio n. 6
0
        public virtual int StoreProduct(Product product)
        {
            DataStore.StoreProduct(product);
            Cache.Add(product.ProductID, product);

            return product.ProductID;
        }