Esempio n. 1
0
        public void SetEmployeeSupervisor(EmployeeSupervisor item)
        {
            // Attention 33 - Must get a valid reference to both objects before continuing

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

            if (employee == null)
            {
                return;
            }

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

            if (supervisor == null)
            {
                return;
            }

            // Make the changes, save, and exit
            employee.Employee2 = supervisor;
            employee.ReportsTo = supervisor.EmployeeId;
            ds.SaveChanges();
        }
        public void PutSetSupervisor(int id, [FromBody] EmployeeSupervisor 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 != item.Employee)
            {
                return;
            }

            // Ensure that we can use the incoming data
            if (ModelState.IsValid)
            {
                // Attempt to update the item
                m.SetEmployeeSupervisor(item);
            }
            else
            {
                return;
            }
        }