public async Task <IActionResult> Index(string email) { var myUser = await _userManager.GetUserAsync(User); AppUserViewModel myUserVM = Mapper.Map <AppUser, AppUserViewModel>(myUser); var user = await _userService.GetByName(email); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userService.GetByName(email)}'."); } var query = _relationshipService.GetByUser(myUserVM, user.Id.ToString()); if (query == null) { ViewData["Status"] = "Add Friend"; ViewData["Action"] = "AddFriend"; } else if (query.Action_user_id == myUser.Id && query.Status == StatusRS.Pending) { ViewData["Status"] = "Đã gửi lời mời"; ViewData["Action"] = "CancelRequest"; } else if (query.Action_user_id == user.Id && query.Status == StatusRS.Pending) { ViewData["Status"] = "Chấp nhận"; ViewData["Action"] = "AcceptFriend"; } else if (query.Status == StatusRS.Accepted) { ViewData["Status"] = "Bạn bè"; ViewData["Action"] = "UnFriend"; } var model = new ProfileViewModel { Id = user.Id, Name = user.FullName, Email = user.Email, PhoneNumber = user.PhoneNumber, StatusMessage = "", BirthDay = user.BirthDay, Avatar = user.Avatar }; return(View(model)); }