public async Task <IActionResult> AddFollower(int ClubId) { var follower = await _ClubMembersService.AddFollowerAsync(ClubId, User); _logger.LogInformation($"User {{{follower.UserId}}} became a follower of Club {{{ClubId}}}."); return(Ok(follower)); }
public async Task <IActionResult> AddFollower(int clubId, string userId) { userId = User.IsInRole("Admin") ? userId : await _userManagerService.GetUserIdAsync(User); return(Ok(_mapper.Map <ClubMembersDTO, ClubMembersViewModel>( await _clubMembersService.AddFollowerAsync(clubId, userId)))); }
public async Task AddFollowerAsyncTest() { //Arrange _clubService.Setup(s => s.GetClubInfoByIdAsync(It.IsAny <int>())).ReturnsAsync(new ClubDTO()); _userManagerService.Setup(s => s.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(new UserDTO()); _repoWrapper .Setup(s => s.ClubMembers.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <ClubMembers, bool> > >(), null)) .ReturnsAsync(new ClubMembers()); //Act await _clubMemberService.AddFollowerAsync(It.IsAny <int>(), It.IsAny <string>()); //Assert _repoWrapper.Verify(i => i.ClubMembers.CreateAsync(It.IsAny <ClubMembers>()), Times.Once()); _repoWrapper.Verify(i => i.ClubMembers.Delete(It.IsAny <ClubMembers>()), Times.Once()); }
public async Task <IActionResult> AddAsClubFollower(int clubIndex, string userId) { userId = User.IsInRole("Admin") ? userId : await _userManagerService.GetUserIdAsync(User); await _clubMembersService.AddFollowerAsync(clubIndex, userId); return(RedirectToAction("UserProfile", "Account", new { userId })); }
public async Task <IActionResult> AddClubFollower(int ClubId, string userId) { try { await _ClubMembersService.AddFollowerAsync(ClubId, userId); _logger.LogInformation($"User {userId} became a follower of Club with id {ClubId}."); return(RedirectToAction("ClubProfile", "Club", new { Clubid = ClubId })); } catch (Exception e) { _logger.LogError($"Exception :{e.Message}"); return(RedirectToAction("HandleError", "Error", new { code = StatusCodes.Status505HttpVersionNotsupported })); } }