Beispiel #1
0
        public List<Product> GetProductList()
        {
            List<Product> products = new List<Product>();

            using (var context = Config.context)
            {
                try
                {

                    var data = context.C_Product.Select(i => i);
                    foreach (C_Product item in data)
                    {
                        Product product = new Product();
                        product.Id = item.id;
                        product.Name = item.name;
                        product.Description = item.description;
                        product.Price = item.price;
                        product.Timestamp = item.timestamp;
                        products.Add(product);
                    }
                }
                catch (Exception ex)
                {
                    // log here
                }
            }
            return products;
        }
Beispiel #2
0
 public Product Convert(C_Product cProduct)
 {
     Product product = new Product();
     product.Id = cProduct.id;
     product.Name = cProduct.name;
     product.Description = cProduct.description;
     product.Price = cProduct.price;
     product.Timestamp = cProduct.timestamp;
     return product;
 }
Beispiel #3
0
 public C_Product Convert(Product product)
 {
     C_Product cProduct = new C_Product();
     cProduct.id = product.Id;
     cProduct.name = product.Name;
     cProduct.description = product.Description;
     cProduct.price = product.Price;
     cProduct.timestamp = product.Timestamp;
     return cProduct;
 }
Beispiel #4
0
 public Product FindProductById(int id)
 {
     Product product = new Product();
     using (var context = Config.context)
     {
         try
         {
             var data = context.C_Product.Single(i => i.id == id);
             return Convert(data);
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return product;
 }
Beispiel #5
0
        public Product FindProductById(int id)
        {
            Product product = new Product();
            using (var context = Config.context)
            {
                try
                {
                    var data = context.C_Product.Single(i => i.id == id);
                    product.Id = data.id;
                    product.Name = data.name;
                    product.Description = data.description;
                    product.Price = data.price;
                    product.Timestamp = data.timestamp;

                }
                catch (Exception ex)
                {
                    // log here
                }
            }
            return product;
        }
Beispiel #6
0
 public bool Edit(Product product)
 {
     /*
     bool completed = false;
     using (var context = Config.context)
     {
         try
         {
             var item = context.C_Product.Single(i => i.id == product.Id);
             var data = Convert(product);
             context.SaveChanges();
             completed = true;
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return completed;
     */
     return false;
 }
Beispiel #7
0
        public bool Insert(Product product)
        {
            bool completed = false;

            return completed;
        }
Beispiel #8
0
 public bool Remove(Product product)
 {
     bool completed = false;
     using (var context = Config.context)
     {
         try
         {
             var item = context.C_Product.Single(i => i.id == product.Id);
             var data = context.C_Product.Remove(item);
             completed = true;
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return completed;
 }
Beispiel #9
0
 public bool Insert(Product product)
 {
     bool completed = false;
     using (var context = Config.context)
     {
         try
         {
             var data = context.C_Product.Add(Convert(product));
             context.SaveChanges();
             completed = true;
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return completed;
 }