Esempio n. 1
0
        public static void DeleteProduct(int productId)
        {
            try
            {
                using (var db = new AlphaContext())
                {
                    var tempProduct = db.Products.Single(x => x.Id == productId);

                    db.Products.Remove(tempProduct);

                    db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:DeleteProduct " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
        }
Esempio n. 2
0
        public static void DeleteSupplier(int supplierId)
        {
            try
            {
                using (var db = new AlphaContext())
                {
                    var tempSupplier = db.Suppliers.Single(x => x.Id == supplierId);

                    db.Suppliers.Remove(tempSupplier);

                    db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:DeleteSupplier " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
        }
Esempio n. 3
0
 public static void UpdateCategory(Category category)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempCategory = db.Categories.Single(x => x.Id == category.Id);
             tempCategory.CategoryName = category.CategoryName;
             tempCategory.Description  = category.Description;
             tempCategory.Picture      = category.Picture;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateCategory " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Esempio n. 4
0
 public static void UpdateOrderDetail(OrderDetail orderDetail)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempOrderDetail = db.OrderDetails.Single(x => x.Id == orderDetail.Id);
             tempOrderDetail.ProductId = orderDetail.ProductId;
             tempOrderDetail.Product   = orderDetail.Product;
             tempOrderDetail.UnitPrice = orderDetail.UnitPrice;
             tempOrderDetail.Quantity  = orderDetail.Quantity;
             tempOrderDetail.Discount  = orderDetail.Discount;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateOrderDetail " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Esempio n. 5
0
 public static void UpdateOrder(Order order)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempOrder = db.Orders.Single(x => x.Id == order.Id);
             tempOrder.OrderDate  = order.OrderDate;
             tempOrder.CustomerId = order.CustomerId;
             tempOrder.EmployeeId = order.EmployeeId;
             tempOrder.Employee   = order.Employee;
             tempOrder.Discount   = order.Discount;
             tempOrder.NetTotal   = order.NetTotal;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateOrder " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Esempio n. 6
0
 public static void UpdateCustomer(Customer customer)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempCustomer = db.Customers.Single(x => x.Id == customer.Id);
             tempCustomer.CompanyName  = customer.CompanyName;
             tempCustomer.ContactName  = customer.CompanyName;
             tempCustomer.ContactTitle = customer.ContactTitle;
             tempCustomer.Address      = customer.Address;
             tempCustomer.City         = customer.City;
             tempCustomer.Phone        = customer.Phone;
             tempCustomer.Fax          = customer.Fax;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateCustomer " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Esempio n. 7
0
 public static void UpdateProduct(Product product)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempProduct = db.Products.Single(x => x.Id == product.Id);
             tempProduct.Quantity      = product.Quantity;
             tempProduct.ProductName   = product.ProductName;
             tempProduct.Supplier      = product.Supplier;
             tempProduct.CategoryId    = product.CategoryId;
             tempProduct.SupplierId    = product.SupplierId;
             tempProduct.UnitPrice     = product.UnitPrice;
             tempProduct.UnitsInStock  = product.UnitsInStock;
             tempProduct.Discountinued = product.Discountinued;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateProduct " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }