예제 #1
0
        public async Task <IActionResult> Profile(string userId = OWNER_DEFAULT)
        {
            var user = (userId == OWNER_DEFAULT) ?
                       await Owner() : _userManager.Users.FirstOrDefault(u => u.Id == userId);

            var ownerId = (await Owner()).Id;

            var friendStatus = "";

            if (_friendsRepository.AreFriends(userId, ownerId))
            {
                friendStatus = "friend";
            }
            else if (_friendsRepository.ArePendingFriends(userId, ownerId))
            {
                friendStatus = "subscribed";
            }
            else
            {
                friendStatus = "";
            }

            var model = new ProfileViewModel
            {
                Email             = user.Email,
                Address           = user.Address,
                IsYourProfile     = userId == OWNER_DEFAULT,
                Id                = user.Id,
                FriendStatus      = friendStatus,
                IsOnline          = await IsOnline(userId),
                Avatar            = user.Avatar,
                AvatarContentType = user.AvatarContentType
            };

            return(View(model));
        }
예제 #2
0
 public IActionResult AreFriends(string firstId, string secondId)
 {
     return(new OkObjectResult(_friendsRepository.AreFriends(firstId, secondId)));
 }