コード例 #1
0
        public async Task <User> GetUserByUsername(string username)
        {
            var repoUser = await Task.Run(() => _repo.GetUserByUsername(username));

            if (repoUser == null)
            {
                return(null);
            }
            return(await Task.Run(() => Mapper.RepoUserToUser(repoUser)));
        }
コード例 #2
0
        public User GetUser(string useremail)
        {
            var repoUser = _repo.GetUserByEmail(useremail);

            if (repoUser == null)
            {
                return(null);
            }
            return(Mapper.RepoUserToUser(repoUser));
        }
コード例 #3
0
        public User GetUser(string username)
        {
            var repoUser = _repo.GetUser(username);

            if (repoUser == null)
            {
                Console.WriteLine("UserLogic.GetUser() was called with a nonexistant username.");
                return(null);
            }
            return(Mapper.RepoUserToUser(repoUser));
        }
コード例 #4
0
        public async Task <List <User> > GetUsers()
        {
            var repoUsers = await _repo.GetUsers();

            var users = new List <User>();

            foreach (var repoUser in repoUsers)
            {
                users.Add(Mapper.RepoUserToUser(repoUser));
            }
            return(users);
        }
コード例 #5
0
        public async Task <List <User> > GetFollowingUsers(string userid)
        {
            List <Repository.Models.FollowingUser> repoAllUsers = await _repo.GetFollowingUsers(userid);

            if (repoAllUsers == null)
            {
                return(null);
            }
            List <User>         allUsers = new List <User>();
            List <Task <User> > tasks    = new List <Task <User> >();

            foreach (Repository.Models.FollowingUser user in repoAllUsers)
            {
                tasks.Add(Task.Run(() => Mapper.RepoUserToUser(user.FolloweeUser)));
            }
            var results = await Task.WhenAll(tasks);

            foreach (var item in results)
            {
                allUsers.Add(item);
            }
            return(allUsers);
        }