Beispiel #1
0
 //edit product in database
 public void EditProduct(OrderManagement.DAL.ProductsTable product)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         ct.Entry(product).State = System.Data.EntityState.Modified;
         ct.SaveChanges();
     }
 }
Beispiel #2
0
 //adds product to the database
 public void AddProduct(OrderManagement.DAL.ProductsTable product)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         ct.ProductsTable.Add(product);
         ct.SaveChanges();
     }
 }
Beispiel #3
0
 //Get products from database by subcategory
 public List <OrderManagement.DAL.ProductsTable> GetProductsBySubCategory(String subCategory)
 {
     using (OrderManagementDBEntities ct = new OrderManagementDBEntities())
     {
         List <OrderManagement.DAL.ProductsTable> products = new List <OrderManagement.DAL.ProductsTable>();
         foreach (var c in ct.ProductsTable.Where(c => c.SubCategory == subCategory))
         {
             OrderManagement.DAL.ProductsTable product = new OrderManagement.DAL.ProductsTable()
             {
                 Id          = c.Id,
                 Name        = c.Name,
                 Category    = c.Category,
                 SubCategory = c.SubCategory,
                 Brand       = c.Brand,
                 Description = c.Description,
                 Price       = c.Price
             };
             products.Add(product);
         }
         return(products);
     }
 }