AssocManyToMany.Controllers.Manager.JobDutyGetByIdWithDetail C# (CSharp) Метод

JobDutyGetByIdWithDetail() публичный Метод

public JobDutyGetByIdWithDetail ( int id ) : JobDutyWithEmployees
id int
Результат JobDutyWithEmployees
        public JobDutyWithEmployees JobDutyGetByIdWithDetail(int id)
        {
            // Attempt to fetch the object
            var o = ds.JobDuties.Include("Employees").SingleOrDefault(j => j.Id == id);

            // Return the result, or null if not found
            return (o == null) ? null : Mapper.Map<JobDutyWithEmployees>(o);
        }

Usage Example

        // GET: Matches/ByJobDutyWithDetails/5
        public ActionResult ByJobDutyWithEmployees(int?id)
        {
            // Attempt to get the matching object
            var o = m.JobDutyGetByIdWithDetail(id.GetValueOrDefault());

            if (o == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Pass the object to the view
                return(View(o));
            }
        }