public async Task <WallResult> Get()
        {
            WallResult result = new WallResult();

            // First Get All friends
            var a = await friends.Get();

            List <GetFriendModel> Friends = a.ToList();

            foreach (GetFriendModel friend in Friends)
            {
                var b = await posts.Get(friend.FriendUserId);

                List <PostDetailsOutputModel> Posts = b.ToList();

                foreach (PostDetailsOutputModel post in Posts)
                {
                    var c = await likes.Get(post.Id);

                    result.Posts.Add(new PostWithLikesDetailsOutputModel()
                    {
                        User  = friend.FriendUserId,
                        Title = post.Title,
                        Text  = post.Text,
                        Likes = c.Likes
                    });
                }
            }

            return(result);
        }
        public async Task Initialize()
        {
            try
            {
                var friendsFetched = await m_friendsService.Get();

                foreach (var friend in friendsFetched)
                {
                    Friends.Add(new FriendViewModel(friend));
                }
            }
            catch (Exception exception)
            {
                //Log it, fix it or show it
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Get()
        {
            try
            {
                var userId = await GetUserId();

                if (!Equals(userId, Guid.Empty))
                {
                    var friends = await _service.Get(userId);

                    return(Ok(friends));
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public async Task Initialize(IHandleFriendChanged friendChangedHandler)
        {
            try
            {
                IsBusy = true;
                var friendsFetched = await m_friendsService.Get();

                foreach (var friend in friendsFetched)
                {
                    Friends.Add(new FriendViewModel(friend, friendChangedHandler));
                }
            }
            catch (Exception exception)
            {
                //Log it, fix it or show it
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 5
0
        public HttpResponseMessage Get(int userId)
        {
            var result = _friendsService.Get(userId);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Get(string q)
        {
            var model = await _friendsService.Get(q);

            return(Ok(model));
        }