diff --git a/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs b/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs index d62b5db..09e9c67 100644 --- a/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs +++ b/src/AzureDevopsService/AzureDevopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs @@ -2,22 +2,21 @@ public class ProfileUserCommandHandler( IUserProfileApiClient userProfileApiClient, - ISendEndpointProvider sendEndpointProvider, IPublishEndpoint publishEndpoint) : IRequestHandler { private readonly IUserProfileApiClient _userProfileApiClient = userProfileApiClient; - private readonly ISendEndpointProvider _sendEndpointProvider = sendEndpointProvider; private readonly IPublishEndpoint _publishEndpoint = publishEndpoint; public async Task Handle(ProfileUserCommand request, CancellationToken cancellationToken) { - ISendEndpoint endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("rabbitmq://rabbitmq/ProfileUserResponce")); - - OneOf adminInfoResponse = await _userProfileApiClient.GetAdminInfo(request.BaseRequest); + // ISendEndpoint endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("rabbitmq://rabbitmq/ProfileUserResponce")); + OneOf adminInfoResponse = + await _userProfileApiClient.GetAdminInfo(request.BaseRequest); if (adminInfoResponse.IsT0) { - OneOf organizationResponce = await _userProfileApiClient.GeUserOrganizations( + OneOf organizationResponce = + await _userProfileApiClient.GeUserOrganizations( new GetUserOrganizationRequest { Email = adminInfoResponse.AsT0.Email, @@ -30,17 +29,5 @@ public async Task Handle(ProfileUserCommand request, CancellationToken cancellat // await endpoint.Send(adminInfoResponse.AsT0, cancellationToken); await _publishEndpoint.Publish(adminInfoResponse.AsT0); } - else - { - //await endpoint.Send( - // new CustomProblemDetailsResponce - // { - // Detail = adminInfoResponse.AsT1.Detail, - // Email = adminInfoResponse.AsT1.Email, - // Path = adminInfoResponse.AsT1.Path, - // Status = adminInfoResponse.AsT1.Status, - // }, - // cancellationToken); - } } } \ No newline at end of file diff --git a/src/TimeLogIdentityService/IdentityService.API/IdentityEndPoint.cs b/src/TimeLogIdentityService/IdentityService.API/IdentityEndPoint.cs index f17633c..72ae022 100644 --- a/src/TimeLogIdentityService/IdentityService.API/IdentityEndPoint.cs +++ b/src/TimeLogIdentityService/IdentityService.API/IdentityEndPoint.cs @@ -19,9 +19,12 @@ public static void AddEndpoints(this IEndpointRouteBuilder app) return Results.Ok(userResponse); }); - _ = app.MapPost("/Login", async (IMediator _mediator, [FromBody] LoginCommand request) => + _ = app.MapPost("/Login", async ( + IMediator mediator, + [FromBody] LoginCommand request, + CancellationToken cancellationToken) => { - ApiResponse userResponse = await _mediator.Send(request); + ApiResponse userResponse = await mediator.Send(request, cancellationToken); if (!userResponse.Succeeded) { return Results.BadRequest(userResponse); diff --git a/src/TimeLogIdentityService/IdentityService.Application/Features/CreateAccount/CreateAccountCommandHandler.cs b/src/TimeLogIdentityService/IdentityService.Application/Features/CreateAccount/CreateAccountCommandHandler.cs index 68e58d0..abf69bc 100644 --- a/src/TimeLogIdentityService/IdentityService.Application/Features/CreateAccount/CreateAccountCommandHandler.cs +++ b/src/TimeLogIdentityService/IdentityService.Application/Features/CreateAccount/CreateAccountCommandHandler.cs @@ -4,7 +4,6 @@ using MassTransit; using MassTransit.Transports; -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member namespace IdentityService.Application.Features.CreateAccount; public class CreateAccountCommandHandler(UserManager userManager, IMediator mediator) diff --git a/src/TimeLogService/TimeLogService.Application/Feature/MessageBroker/Consumer/ProfileUser/ProfileUserConsumer.cs b/src/TimeLogService/TimeLogService.Application/Feature/MessageBroker/Consumer/ProfileUser/ProfileUserConsumer.cs index 9cb7d02..148b2c2 100644 --- a/src/TimeLogService/TimeLogService.Application/Feature/MessageBroker/Consumer/ProfileUser/ProfileUserConsumer.cs +++ b/src/TimeLogService/TimeLogService.Application/Feature/MessageBroker/Consumer/ProfileUser/ProfileUserConsumer.cs @@ -1,6 +1,11 @@ namespace TimeLogService.Application.Feature.MessageBroker.Consumer.ProfileUser; -public class ProfileUserConsumer(ILogger logger, IMediator mediator, IRepository repository, IRepository repositoryOrganization) : IConsumer, IConsumer +public class ProfileUserConsumer( + ILogger logger, + IMediator mediator, + IRepository repository, + IRepository repositoryOrganization) + : IConsumer, IConsumer { private readonly ILogger _logger = logger; private readonly IMediator _mediator = mediator; @@ -9,29 +14,31 @@ public class ProfileUserConsumer(ILogger logger, IMediator public async Task Consume(ConsumeContext context) { - User user = await _repository.GetSingleAsync(x => x.UserId == context.Message!.Id); + User? user = await _repository.GetSingleAsync(x => x.UserId == context.Message!.Id); if (user is null) { await _mediator.Send(new AddUserCommand(context.Message)); } - if (context.Message.UserAccount is not null && context.Message.UserAccount!.Count > 0) + if (context.Message.UserAccount is not null && context.Message.UserAccount.Count > 0) { - IReadOnlyList organizationList = await _repositoryOrganization.GetManyAsync(x => x.UserId == context.Message!.Id); + IReadOnlyList organizationList = await _repositoryOrganization + .GetManyAsync(x => x.UserId == context.Message!.Id); - HashSet existingAccountIds = new(organizationList.Select(x => x.AccountId)); + HashSet existingAccountIds = [.. organizationList.Select(x => x.AccountId)]; List organizations = []; foreach (UserOrganization org in context.Message.UserAccount!.Value) { - if (!existingAccountIds.Contains(org.AccountId)) + if (!existingAccountIds.Contains(org.AccountId) + && org.AccountUri is not null) { organizations.Add(new Organization { AccountId = org!.AccountId, - AccountUri = org!.AccountUri!.ToString(), + AccountUri = org.AccountUri, Name = org.AccountName, UserId = context.Message!.Id, IsAionTimeApproved = false, @@ -48,12 +55,9 @@ public async Task Consume(ConsumeContext context) _logger.LogInformation(JsonConvert.SerializeObject(context.Message)); } -#pragma warning disable format -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task Consume(ConsumeContext context) -#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously -#pragma warning restore format { + await Task.Delay(1); _logger.LogInformation(JsonConvert.SerializeObject(context.Message)); } } \ No newline at end of file diff --git a/src/TimeLogService/TimeLogService.Domain/Models/dbo/AionTimeSubscription.cs b/src/TimeLogService/TimeLogService.Domain/Models/dbo/AionTimeSubscription.cs index 9b62bc1..0269ae5 100644 --- a/src/TimeLogService/TimeLogService.Domain/Models/dbo/AionTimeSubscription.cs +++ b/src/TimeLogService/TimeLogService.Domain/Models/dbo/AionTimeSubscription.cs @@ -8,7 +8,7 @@ public partial class AionTimeSubscription : BaseEntity public int OrganizationId { get; set; } - public virtual ICollection? AionTimeSubscriptionHistories { get; set; } // = new List(); + public virtual ICollection? AionTimeSubscriptionHistories { get; private set; } public virtual Organization? Organization { get; set; } } \ No newline at end of file diff --git a/src/TimeLogService/TimeLogService.Domain/Models/dbo/Organization.cs b/src/TimeLogService/TimeLogService.Domain/Models/dbo/Organization.cs index f8b6cfc..dda9dd5 100644 --- a/src/TimeLogService/TimeLogService.Domain/Models/dbo/Organization.cs +++ b/src/TimeLogService/TimeLogService.Domain/Models/dbo/Organization.cs @@ -8,13 +8,13 @@ public partial class Organization : BaseEntity public string AccountId { get; set; } = null!; - public string AccountUri { get; set; } = null!; + public required Uri AccountUri { get; set; } public bool IsAionTimeApproved { get; set; } - public virtual ICollection? AionTimeSubscriptions { get; set; } + public virtual ICollection? AionTimeSubscriptions { get; private set; } - public virtual ICollection? Projects { get; set; } + public virtual ICollection? Projects { get; private set; } public virtual User? User { get; set; } } \ No newline at end of file diff --git a/src/TimeLogService/TimeLogService.Domain/Models/dbo/Project.cs b/src/TimeLogService/TimeLogService.Domain/Models/dbo/Project.cs index 3e30af3..63238ae 100644 --- a/src/TimeLogService/TimeLogService.Domain/Models/dbo/Project.cs +++ b/src/TimeLogService/TimeLogService.Domain/Models/dbo/Project.cs @@ -14,9 +14,9 @@ public partial class Project : BaseEntity public DateTime? LastUpdateTime { get; set; } - public string Url { get; set; } = null!; + public required Uri Url { get; set; } public virtual Organization? Organization { get; set; } - public virtual ICollection? WorkItems { get; set; } // = new List(); + public virtual ICollection? WorkItems { get; private set; } } \ No newline at end of file diff --git a/src/TimeLogService/TimeLogService.Domain/Models/dbo/User.cs b/src/TimeLogService/TimeLogService.Domain/Models/dbo/User.cs index d82c40e..14ac9d1 100644 --- a/src/TimeLogService/TimeLogService.Domain/Models/dbo/User.cs +++ b/src/TimeLogService/TimeLogService.Domain/Models/dbo/User.cs @@ -18,5 +18,5 @@ public partial class User : BaseEntity public int Revision { get; set; } - public virtual ICollection? Organizations { get; set; } // = new List(); + public virtual ICollection? Organizations { get; private set; } } \ No newline at end of file diff --git a/src/TimeLogService/TimeLogService.Domain/Models/dbo/WorkItem.cs b/src/TimeLogService/TimeLogService.Domain/Models/dbo/WorkItem.cs index 9686452..be1565d 100644 --- a/src/TimeLogService/TimeLogService.Domain/Models/dbo/WorkItem.cs +++ b/src/TimeLogService/TimeLogService.Domain/Models/dbo/WorkItem.cs @@ -12,7 +12,7 @@ public partial class WorkItem : BaseEntity public virtual Project? Project { get; set; } - public virtual ICollection? WorkItemHistories { get; set; } // = new List(); + public virtual ICollection? WorkItemHistories { get; private set; } - public virtual ICollection? WorkItemTimeLogs { get; set; } // = new List(); + public virtual ICollection? WorkItemTimeLogs { get; private set; } } \ No newline at end of file