AssocSelf.Controllers.Manager.EmployeeGetByIdWIthOrgInfo C# (CSharp) Метод

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

public EmployeeGetByIdWIthOrgInfo ( int id ) : EmployeeWithOrgInfo
id int
Результат EmployeeWithOrgInfo
        public EmployeeWithOrgInfo EmployeeGetByIdWIthOrgInfo(int id)
        {
            // Attempt to get the matching object
            var o = ds.Employees.Include("Employee1").Include("Employee2")
                .SingleOrDefault(e => e.EmployeeId == id);

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

Usage Example

Пример #1
0
        // GET: Employees/Details/5
        public ActionResult Details(int?id)
        {
            // Attempt to get the matching object
            var o = m.EmployeeGetByIdWIthOrgInfo(id.GetValueOrDefault());

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