private async Task <UserAgent> GetAgentAndUser(string userName, string agentName) { var agentInAspNetUsers = await userManager.FindByNameAsync(agentName); var userInAspNetUsers = await userManager.FindByNameAsync(userName); if (agentInAspNetUsers == null || userInAspNetUsers == null) { return(null); } IEnumerable <User> user = iUserManager.GetAllWithInclude(u => u.UserAddress, u => u.AspNetUsersId == userInAspNetUsers.Id); Agent agent = agentManager.GetFirstOrDefaultByParam(a => a.AspNetUsersId == agentInAspNetUsers.Id); return(new UserAgent { User = user.FirstOrDefault(), Agent = agent }); }