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); } }
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); } }