// Get All management with contact // DEFAULT // RETURNS ALL MANAGERS WITH: Contacts public IEnumerable <ManagementContactMapper> GetManagementsWithContact() { var content = db.Managements.ToList(); if (content.Count() == 0) { return(null); } else { List <ManagementContactMapper> managements = new List <ManagementContactMapper>(); ContactsHelper contact = new ContactsHelper(); foreach (var item in content) { ManagementContactMapper management = new ManagementContactMapper { ManagerId = item.managerId, ContactId = item.contactId ?? 0, DepartmentName = item.departmentName, Contact = contact.GetContact(item.contactId ?? 0) }; managements.Add(management); } return(managements); } }
// Get One management with contact // DEFAULT // RETURNS ONE MANAGER BY ID WITH: Contacts public ManagementContactMapper GetManagementWithContact(int managerId) { var content = db.Managements.FirstOrDefault(j => j.managerId == managerId); if (content == null) { return(null); } else { ContactsHelper contact = new ContactsHelper(); ManagementContactMapper management = new ManagementContactMapper { ManagerId = content.managerId, ContactId = content.contactId ?? 0, DepartmentName = content.departmentName, Contact = contact.GetContact(content.contactId ?? 0) }; return(management); } }