コード例 #1
0
        public void CustomerSetSupportRep(int?id, [FromBody] CustomerSupportRep item)
        {
            // Ensure that an "editedItem" is in the entity body
            if (item == null)
            {
                return;
            }

            // Ensure that the id value in the URI matches the id value in the entity body
            if (id.GetValueOrDefault() != item.CustomerId)
            {
                return;
            }

            // Ensure that we can use the incoming data
            if (ModelState.IsValid)
            {
                // Attempt to update the item
                m.CustomerSetSupportRep(item);
            }
            else
            {
                return;
            }
        }
コード例 #2
0
        // Attention 37 - Set support rep command
        public void CustomerSetSupportRep(CustomerSupportRep item)
        {
            // Get a reference to the customer
            var customer = ds.Customers.Find(item.CustomerId);

            if (customer == null)
            {
                return;
            }

            // Get a reference to the employee
            var employee = ds.Employees.Find(item.SupportRepId);

            if (employee == null)
            {
                return;
            }

            // Make the changes, save, and exit
            customer.Employee     = employee;
            customer.SupportRepId = employee.EmployeeId;
            ds.SaveChanges();
        }