public async Task <IActionResult> Specialities() { var vm = new SpecialitiesViewModel { Specialities = await _doctorService.GetSpecialities().Select(x => x).ToListAsync() }; return(View(vm)); }
public async Task <IActionResult> Index(string DepId) { var dep = await(from i in DBContext.Departments.Include(s => s.Specialities).Include(h => h.HeadTeacher) where i.Id.ToString() == DepId select i).FirstOrDefaultAsync(); var specs = await(from d in DBContext.Specialities where dep.Specialities.Contains(d) select d).ToListAsync(); if (dep != null && specs != null) { var inst = await(from i in DBContext.Institutions.Include(d => d.Departments).Include(m => m.Manager) where i.Departments.Contains(dep) select i).FirstOrDefaultAsync(); //var manager var model = new SpecialitiesViewModel() { Specialities = specs, DepartmentId = DepId, DepartmentName = dep.Name, InstId = inst.Id.ToString(), InstManagerId = inst.Manager.Id.ToString(), InstManagerEmail = inst.Manager.Email, HeadTeacherId = dep.HeadTeacher.Id.ToString(), HeadTeacherEmail = dep.HeadTeacher.Email, userGrants = await checkService.getUserGrants(User) }; return(View(model)); } else { ModelState.AddModelError("Index", "No such department"); } return(RedirectToAction("Index")); }