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

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

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

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

Usage Example

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

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