public async Task <IActionResult> Index([FromServices] ITeacherAccountService teacherAccountService, [FromServices] IStudentAccountService studentAccountService) { var TeacherAccs = await teacherAccountService.GetTeacherAccountsFromDbAsync(); var StudentAccs = await studentAccountService.GetStudentAccountsFromDbAsync(); int[] numbers = { TeacherAccs.Count(), StudentAccs.Count() }; ViewBag.Message = numbers; return(View()); }
public async Task <FullAccountDto> SearchAccount(string userName) { var teacherTask = Task.Run(() => _teacherAccountRepository.GetTeacherAccountsFromDbAsync().Result.FirstOrDefault(o => o.UserName == userName)); var studentTask = Task.Run(() => _studentAccountRepository.GetStudentAccountsFromDbAsync().Result.FirstOrDefault(o => o.UserName == userName)); var teacherAccount = await teacherTask; var studentAccount = await studentTask; if (teacherAccount != default) { return(teacherAccount.Map <ITeacherAccount, FullAccountDto>()); } else { return(studentAccount.Map <IStudentAccount, FullAccountDto>()); } }