public async Task <IActionResult> Index(int?id) { var vm = new PatientServiceRelatedEntity(); vm.employees = await _context.Employee.Include(i => i.PEServices) .ThenInclude(i => i.Patient).ToListAsync(); if (id != null) { ViewData["EmployeeId"] = id.Value; Employee employee = vm.employees.Where(i => i.Id == id.Value).Single(); //vm.services = employee.PEServices.Select(s => s.Service); vm.patients = employee.PEServices.Select(s => s.Patient); } //var hospitalContext = _context.Employee.Include(e => e.EmployeeCategory).Include(e => e.department).Include(e => e.designation); return(View(vm)); }
public async Task <IActionResult> ReadRelatedDate(int?id, int?serviceId) { var relatedDate = new PatientServiceRelatedEntity(); relatedDate.patientServices = await _db.PatientService.Include(s => s.Services) .Include(s => s.Patient) .Include(s => s.Employee) .ThenInclude(s => s.department).ToListAsync(); if (id != null) { ViewData["PatientServiceId"] = id.Value; PatientServices ps = relatedDate.patientServices.Where(i => i.Id == id.Value).Single(); } return(View(relatedDate)); }