public async Task <IActionResult> Friendship(string username) { var userId = this.userManager.GetUserId(this.User); FriendshipViewModel viewModel = await this.iGService.Friendship(userId, username); return(this.View(viewModel)); }
public IActionResult Update(int id, [FromBody] FriendshipViewModel model) { // map model to entity and set id var friendship = _mapper.Map <Friendship>(model); friendship.Id = id; if (friendship == null) { return(NotFound()); } try { // update user _friendshipService.Update(friendship); _log.LogInformation("Friendship updated", $"Friendship with Id {model.Id} has been updated."); return(Ok()); } catch (AppException ex) { _log.LogError("Error occured while updating Friendship", "", $"{ex.Message}"); // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public async Task <FriendshipViewModel> Friendship(string userId, string username) { this.instaApi = this.api.GetInstance(userId); var profile = await this.instaApi.UserProcessor.GetUserInfoByUsernameAsync(username); var status = await this.instaApi.UserProcessor.GetFriendshipStatusAsync(profile.Value.Pk); FriendshipViewModel model = new FriendshipViewModel { IGUserName = username, IGFullName = profile.Value.FullName, ProfilePicUrl = profile.Value.ProfilePicUrl, Friends = status.Value.FollowedBy && status.Value.Following, Caption = profile.Value.Biography, }; return(model); }