public async Task <UseCaseResult> Handle([NotNull] GetEditRoles request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var diver = await diverRepository.FindByUserNameAsync(request.UserName); if (diver == null) { return(UseCaseResult.NotFound()); } var allRoles = roleManager.Roles.Select(r => r.Name); var assignedRoles = await userManager.GetRolesAsync(diver.User); request.OutputPort?.Output( new GetEditRolesOutput( diver.User.UserName, diver.Fullname, allRoles, assignedRoles)); return(UseCaseResult.Success()); }
public async Task <Diver> GetCurrentDiverAsync() { if (string.IsNullOrWhiteSpace(currentUserInformation.UserName)) { return(null); } return(await diverRepository.FindByUserNameAsync(currentUserInformation.UserName)); }
public GetEventEditDetailsInteractorTests() { A.CallTo(() => diverRepository.FindByUserNameAsync(A <string> ._)) .ReturnsLazily(call => Task.FromResult( (string)call.Arguments[0] == validUserName ? CreateDiverJohnDoe() : null)); A.CallTo(() => eventRepository.FindByIdAsync(A <Guid> ._)) .ReturnsLazily(call => Task.FromResult( (Guid)call.Arguments[0] == validEventId ? new Tauchbolde.Domain.Entities.Event { Id = validEventId, Name = "Test Event", Location = "", MeetingPoint = "", Description = "", OrganisatorId = validDiverId, Organisator = CreateDiverJohnDoe() } : null)); A.CallTo(() => clock.Now()).Returns(new DateTime(2019, 9, 1, 19, 0, 0)); A.CallTo(() => currentUser.GetCurrentDiverAsync()) .ReturnsLazily(() => Task.FromResult( new Diver { Id = validDiverId, Fullname = "Joe Doe", User = new IdentityUser("joe.doe") { Email = "*****@*****.**" } })); interactor = new GetEventEditDetailsInteractor(logger, eventRepository, clock, currentUser); }