예제 #1
0
        public async Task <JsonResult> GetCurrentUserFriends()
        {
            var user = await _userService.GetUserByName(HttpContext.User.Identity.Name);

            var friends = await _friendsService.GetFriendsForUser(user);

            var result = friends.Select(f => new UserViewModel(f));

            return(Json(result));
        }
예제 #2
0
        public async Task <IActionResult> GetFriendsForUser(string FriendId)
        {
            try
            {
                var res = await _service.GetFriendsForUser(FriendId);

                return(Ok(res));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "FriendsAPIController.GetFriends");
                return(new StatusCodeResult(500));
            }
        }
        public ActionResult <IEnumerable <FriendsDto> > GetFriendsForUser(int userId)
        {
            try
            {
                var friendsDto = _friendsService.GetFriendsForUser(userId);

                return(Ok(friendsDto));
            }
            catch (FlowException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception)
            {
                return(StatusCode(500, "An error has occured!Try again later!"));
            }
        }