public Customer UpdateCustomer(Customer customer2BUpdated)
        {
            Customer oldCustomer = _context.Customers.Find(customer2BUpdated.Id);

            _context.Entry(oldCustomer).CurrentValues.SetValues(customer2BUpdated);
            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(customer2BUpdated);
        }
        public Product UpdateInventory(Product inv1)
        {
            Product oldinv = _context.Products.Find(inv1.id);

            _context.Entry(oldinv).CurrentValues.SetValues(inv1);
            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(inv1);
        }
        public CustomerCart UpdateCustomerCart(CustomerCart customerCart2BUpated)
        {
            CustomerCart oldCustomerCart = _context.CustomerCarts.Find(customerCart2BUpated.Id);

            _context.Entry(oldCustomerCart).CurrentValues.SetValues(customerCart2BUpated);

            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(customerCart2BUpated);
        }
        public CustomerOrderHistory UpdateCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BUpated)
        {
            CustomerOrderHistory oldCustomerOrderHistory = _context.CustomerOrderHistories.Find(customerOrderHistory2BUpated.Id);

            _context.Entry(oldCustomerOrderHistory).CurrentValues.SetValues(customerOrderHistory2BUpated);

            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(customerOrderHistory2BUpated);
        }
        public CustomerOrderLineItem UpdateCustomerOrderLineItem(CustomerOrderLineItem customerOrderLineItem2BUpated)
        {
            CustomerOrderLineItem oldCustomerOrderLineItem = _context.CustomerOrderLineItems.Find(customerOrderLineItem2BUpated.Id);

            _context.Entry(oldCustomerOrderLineItem).CurrentValues.SetValues(customerOrderLineItem2BUpated);

            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(customerOrderLineItem2BUpated);
        }
示例#6
0
        public Customer UpdateCustomer(Customer customer2BUpdated)
        {
            Customer oldCustomer = _context.Customers.Find(customer2BUpdated.Id);


            _context.Entry(oldCustomer).CurrentValues.SetValues(customer2BUpdated);

            _context.SaveChanges();

            //This method clears the change tracker to drop all tracked entities
            _context.ChangeTracker.Clear();
            return(customer2BUpdated);
        }
示例#7
0
        public Manager UpdateManager(Manager manager2BUpdated)
        {
            Manager oldManager = _context.Managers.Find(manager2BUpdated.Id);


            _context.Entry(oldManager).CurrentValues.SetValues(manager2BUpdated);

            _context.SaveChanges();

            //This method clears the change tracker to drop all tracked entities
            _context.ChangeTracker.Clear();
            return(manager2BUpdated);
        }
示例#8
0
        public Location UpdateLocation(Location location2BUpdated)
        {
            Location oldLocation = _context.Locations.Find(location2BUpdated.Id);


            _context.Entry(oldLocation).CurrentValues.SetValues(location2BUpdated);

            _context.SaveChanges();

            //This method clears the change tracker to drop all tracked entities
            _context.ChangeTracker.Clear();
            return(location2BUpdated);
        }
示例#9
0
        public Product UpdateProduct(Product product2BUpdated)
        {
            Product oldProduct = _context.Products.Find(product2BUpdated.Id);


            _context.Entry(oldProduct).CurrentValues.SetValues(product2BUpdated);

            _context.SaveChanges();

            //This method clears the change tracker to drop all tracked entities
            _context.ChangeTracker.Clear();
            return(product2BUpdated);
        }
示例#10
0
        public InventoryLineItem UpdateInventoryLineItem(InventoryLineItem inventoryLineItem2BUpdated)
        {
            InventoryLineItem oldInventoryLineItem = _context.InventoryLineItems.Find(inventoryLineItem2BUpdated.Id);


            _context.Entry(oldInventoryLineItem).CurrentValues.SetValues(inventoryLineItem2BUpdated);

            _context.SaveChanges();

            //This method clears the change tracker to drop all tracked entities
            _context.ChangeTracker.Clear();
            return(inventoryLineItem2BUpdated);
        }
示例#11
0
        public Inventory UpdateInventory(Inventory inv)
        {
            try
            {
                Inventory oldInv = _context.Inventories
                                   .FirstOrDefault(i => i.Id == inv.Id);

                _context.Entry(oldInv).CurrentValues.SetValues(inv);

                _context.SaveChanges();
                _context.ChangeTracker.Clear();

                return(inv);
            }
            catch (Exception)
            {
                //Log.Error("That product is not in stock at the selected location!");
                AddInventory(inv);
                return(inv);
            }
        }