示例#1
0
        public void PutClearJobDuty(int id, [FromBody] EmployeeJobDuty 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.ClearEmployeeJobDuty(item);
            }
            else
            {
                return;
            }
        }
示例#2
0
        public void ClearEmployeeJobDuty(EmployeeJobDuty item)
        {
            // Get a reference to the employee
            // Must bring back its collection of job duties
            var employee = ds.Employees
                           .Include("JobDuties")
                           .SingleOrDefault(e => e.Id == item.Employee);

            if (employee == null)
            {
                return;
            }

            // Get a reference to the job duty
            // Notice that we're getting it from the employee object (above)
            var jobDuty = employee.JobDuties
                          .SingleOrDefault(j => j.Id == item.JobDuty);

            if (jobDuty == null)
            {
                return;
            }

            // Make the changes, save, and exit
            if (employee.JobDuties.Remove(jobDuty))
            {
                ds.SaveChanges();
            }
        }
示例#3
0
        public void SetEmployeeJobDuty(EmployeeJobDuty item)
        {
            // Get a reference to the employee
            // Must bring back its collection of job duties
            var employee = ds.Employees
                           .Include("JobDuties")
                           .SingleOrDefault(e => e.Id == item.Employee);

            if (employee == null)
            {
                return;
            }

            // Get a reference to the job duty
            var jobDuty = ds.JobDuties.Find(item.JobDuty);

            if (jobDuty == null)
            {
                return;
            }

            // Make the changes, save, and exit
            employee.JobDuties.Add(jobDuty);
            ds.SaveChanges();
        }
示例#4
0
        public void ClearEmployeeJobDuty(EmployeeJobDuty item)
        {
            // Get a reference to the employee
            // Must bring back its collection of job duties
            var employee = ds.Employees
                .Include("JobDuties")
                .SingleOrDefault(e => e.Id == item.Employee);
            if (employee == null) { return; }

            // Get a reference to the job duty
            // Notice that we're getting it from the employee object (above)
            var jobDuty = employee.JobDuties
                .SingleOrDefault(j => j.Id == item.JobDuty);
            if (jobDuty == null) { return; }

            // Make the changes, save, and exit
            if (employee.JobDuties.Remove(jobDuty))
            {
                ds.SaveChanges();
            }
        }
示例#5
0
        public void SetEmployeeJobDuty(EmployeeJobDuty item)
        {
            // Get a reference to the employee
            // Must bring back its collection of job duties
            var employee = ds.Employees
                .Include("JobDuties")
                .SingleOrDefault(e => e.Id == item.Employee);
            if (employee == null) { return; }

            // Get a reference to the job duty
            var jobDuty = ds.JobDuties.Find(item.JobDuty);
            if (jobDuty == null) { return; }

            // Make the changes, save, and exit
            employee.JobDuties.Add(jobDuty);
            ds.SaveChanges();
        }