Skip to content

Commit

Permalink
optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
msaad committed Sep 17, 2024
1 parent e64f317 commit 5c5f12b
Show file tree
Hide file tree
Showing 29 changed files with 171 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public async Task<OneOf<AllProjectResponce, CustomProblemDetailsResponce>> AllPr
if (projectsResult.StatusCode == HttpStatusCode.OK)
{
AllProjectResponce projects = await projectsResult.Content.ReadFromJsonAsync<AllProjectResponce>();
projects.Path = request.Path;
projects!.Path = request.Path;
projects.Email = request.Email;

return projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task<OneOf<UserAccount, CustomProblemDetailsResponce>> GeUserOrgani
if (userOrganizationResult.StatusCode == HttpStatusCode.OK)
{
UserAccount responce = await userOrganizationResult.Content.ReadFromJsonAsync<UserAccount>();
responce.Path = request.Path;
responce!.Path = request.Path;
responce.Email = request.Email;

return responce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task<OneOf<WiqlResponses, WiqlBadRequestResponce>> GetWorkItemByUse
if (workItemResponse.StatusCode == HttpStatusCode.OK)
{
WiqlResponses? wiqlResponses = await workItemResponse.Content.ReadFromJsonAsync<WiqlResponses>();
wiqlResponses.Email = wiqlRequest.Email;
wiqlResponses!.Email = wiqlRequest.Email;
wiqlResponses.Path = wiqlRequest.Path;
return wiqlResponses;
}
Expand All @@ -28,7 +28,7 @@ public async Task<OneOf<WiqlResponses, WiqlBadRequestResponce>> GetWorkItemByUse
if (workItemResponse.StatusCode == HttpStatusCode.BadRequest)
{
WiqlBadRequestResponce wiqlBadResponses = await workItemResponse.Content.ReadFromJsonAsync<WiqlBadRequestResponce>();
wiqlBadResponses.Path = wiqlRequest.Path;
wiqlBadResponses!.Path = wiqlRequest.Path;
wiqlBadResponses.Email = wiqlRequest.Email;

return wiqlBadResponses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public async Task Handle(ProfileUserCommand request, CancellationToken cancellat
OneOf<UserAccount, CustomProblemDetailsResponce> organizationResponce = await _userProfileApiClient.GeUserOrganizations(
new GetUserOrganizationRequest
{
Email = adminInfoResponse!.AsT0!.Email,
MemberId = adminInfoResponse!.AsT0!.Id,
Path = adminInfoResponse!.AsT0!.Path,
Email = adminInfoResponse.AsT0.Email,
MemberId = adminInfoResponse.AsT0.Id,
Path = adminInfoResponse.AsT0.Path,
});

adminInfoResponse.AsT0.UserAccount = organizationResponce.AsT0;
Expand All @@ -31,10 +31,10 @@ public async Task Handle(ProfileUserCommand request, CancellationToken cancellat
await endpoint.Send(
new CustomProblemDetailsResponce
{
Detail = adminInfoResponse!.AsT1!.Detail,
Email = adminInfoResponse!.AsT1!.Email,
Path = adminInfoResponse!.AsT1!.Path,
Status = adminInfoResponse!.AsT1!.Status,
Detail = adminInfoResponse.AsT1.Detail,
Email = adminInfoResponse.AsT1.Email,
Path = adminInfoResponse.AsT1.Path,
Status = adminInfoResponse.AsT1.Status,
},
cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public async Task Handle(ProjectCommand request, CancellationToken cancellationT
OneOf<AllProjectResponce, CustomProblemDetailsResponce> projectsResponse = await _projectService.AllProjectUnderOrganization(request.Request);
if (projectsResponse.IsT0)
{
await endpoint.Send(projectsResponse!.AsT0, cancellationToken);
await endpoint.Send(projectsResponse.AsT0, cancellationToken);
}
else
{
await endpoint.Send(projectsResponse!.AsT1, cancellationToken);
await endpoint.Send(projectsResponse.AsT1, cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public async Task Handle(WorkItemCommand request, CancellationToken cancellation

if (workItemResponse.IsT0)
{
await endpoint.Send(workItemResponse!.AsT0, cancellationToken);
await endpoint.Send(workItemResponse.AsT0, cancellationToken);
}
else
{
await endpoint.Send(workItemResponse!.AsT1, cancellationToken);
await endpoint.Send(workItemResponse.AsT1, cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace AzureDevopsService.Contracts.AzureRequestResourceModel
namespace AzureDevopsService.Contracts.AzureRequestResourceModel;

public class AllProjectUnderOrganizationRequest : BaseRequest
{
public class AllProjectUnderOrganizationRequest : BaseRequest
{
public required string OrganizationName { get; set; }
}
public required string OrganizationName { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class BaseRequest
{
public string Email { get; set; }
public string Email { get; set; } = string.Empty;

public string Path { get; set; }
public string Path { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using AzureDevopsService.Contracts.AzureRequestResourceModel;

namespace AzureDevopsService.Contracts.AzureRequestResourceModel
namespace AzureDevopsService.Contracts.AzureRequestResourceModel;

public class WiqlRequest : BaseRequest
{
public class WiqlRequest : BaseRequest
{
[JsonProperty("query")]
public string Query { get; set; } = string.Empty;
[JsonProperty("query")]
public string Query { get; set; } = string.Empty;

[JsonProperty("organization")]
public string Organization { get; set; } = string.Empty;
[JsonProperty("organization")]
public string Organization { get; set; } = string.Empty;

[JsonProperty("project")]
public string Project { get; set; } = string.Empty;
[JsonProperty("project")]
public string Project { get; set; } = string.Empty;

[JsonProperty("team")]
public string Team { get; set; } = string.Empty;
[JsonProperty("team")]
public string Team { get; set; } = string.Empty;

[JsonProperty("apiVersion")]
public string ApiVersion { get; set; } = string.Empty;
}
[JsonProperty("apiVersion")]
public string ApiVersion { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace AzureDevopsService.Contracts.AzureRequestResourceModel
namespace AzureDevopsService.Contracts.AzureRequestResourceModel;

public class WorkItemRequest : BaseRequest
{
public class WorkItemRequest : BaseRequest
{
public required string OrganisationName { get; set; }
public required string OrganisationName { get; set; }

public required string ProjectName { get; set; }
}
public required string ProjectName { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
namespace AzureDevopsService.Contracts.AzureResponceModel
using System.Collections;

namespace AzureDevopsService.Contracts.AzureResponceModel;

public class AllProjectResponce : BaseRequest
{
public class AllProjectResponce : BaseRequest
{
[property: JsonProperty(PropertyName = "count", NullValueHandling = NullValueHandling.Ignore)]
public int? Count { get; set; }
[property: JsonProperty(PropertyName = "count", NullValueHandling = NullValueHandling.Ignore)]
public int Count { get; set; }

[property: JsonProperty(PropertyName = "value", NullValueHandling = NullValueHandling.Ignore)]
#pragma warning disable CA1002 // Do not expose generic lists
#pragma warning disable CA2227 // Collection properties should be read only
public List<Project>? Value { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
#pragma warning restore CA1002 // Do not expose generic lists
}
[property: JsonProperty(PropertyName = "value", NullValueHandling = NullValueHandling.Ignore)]
public IEnumerable<Project> Value { get; set; } = Enumerable.Empty<Project>();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace AzureDevopsService.Contracts.AzureResponceModel
namespace AzureDevopsService.Contracts.AzureResponceModel;

public class CustomProblemDetailsResponce : ProblemDetails
{
public class CustomProblemDetailsResponce : ProblemDetails
{
public string? Email { get; set; }
public string Email { get; set; } = string.Empty;

public string? Path { get; set; }
}
public string Path { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
namespace AzureDevopsService.Contracts.AzureResponceModel
namespace AzureDevopsService.Contracts.AzureResponceModel;

public class Project
{
public class Project
{
[JsonProperty("id")]
public Guid Id { get; set; }
[JsonProperty("id")]
public Guid Id { get; set; }

[JsonProperty("name")]
public string? Name { get; set; }
[JsonProperty("name")]
public string Name { get; set; } = string.Empty;

[JsonProperty("url")]
public Uri? Url { get; set; }
[JsonProperty("url")]
public Uri? Url { get; set; }

[JsonProperty("state")]
public string? State { get; set; }
[JsonProperty("state")]
public string State { get; set; } = string.Empty;

[JsonProperty("revision")]
public int Revision { get; set; }
[JsonProperty("revision")]
public int Revision { get; set; }

[JsonProperty("visibility")]
public string? Visibility { get; set; }
[JsonProperty("visibility")]
public string Visibility { get; set; } = string.Empty;

[JsonProperty("lastUpdateTime")]
public DateTime LastUpdateTime { get; set; }
}
[JsonProperty("lastUpdateTime")]
public DateTime LastUpdateTime { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
namespace AzureDevopsService.Contracts.AzureResponceModel
namespace AzureDevopsService.Contracts.AzureResponceModel;

public class UserAccount : BaseRequest
{
public class UserAccount : BaseRequest
{
[property: JsonProperty(PropertyName = "count", NullValueHandling = NullValueHandling.Ignore)]
public int? Count { get; set; }
[property: JsonProperty(PropertyName = "count", NullValueHandling = NullValueHandling.Ignore)]
public int Count { get; set; }

[property: JsonProperty(PropertyName = "value", NullValueHandling = NullValueHandling.Ignore)]
#pragma warning disable CA1002 // Do not expose generic lists
#pragma warning disable CA2227 // Collection properties should be read only
public List<UserOrganization>? Value { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
#pragma warning restore CA1002 // Do not expose generic lists
}
[property: JsonProperty(PropertyName = "value", NullValueHandling = NullValueHandling.Ignore)]
public IEnumerable<UserOrganization> Value { get; set; } = Enumerable.Empty<UserOrganization>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
public class UserOrganization
{
[JsonProperty("accountId")]
public string? AccountId { get; set; }
public string AccountId { get; set; } = string.Empty;

[JsonProperty("accountUri")]
public Uri? AccountUri { get; set; }
public Uri? AccountUri { get; set; };

[JsonProperty("accountName")]
public string? AccountName { get; set; }
public string AccountName { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
public class UserProfile : BaseRequest
{
[JsonProperty("displayName")]
public string? DisplayName { get; set; }
public string DisplayName { get; set; } = string.Empty;

[JsonProperty("publicAlias")]
public string? PublicAlias { get; set; }
public string PublicAlias { get; set; } = string.Empty;

[JsonProperty("emailAddress")]
public string? EmailAddress { get; set; }
public string EmailAddress { get; set; } = string.Empty;

[JsonProperty("coreRevision")]
public int CoreRevision { get; set; }
Expand All @@ -18,11 +18,11 @@ public class UserProfile : BaseRequest
public DateTime TimeStamp { get; set; }

[JsonProperty("id")]
public string? Id { get; set; }
public string Id { get; set; } = string.Empty;

[JsonProperty("revision")]
public int Revision { get; set; }

[JsonProperty("UserAccount")]
public UserAccount? UserAccount { get; set; }
public UserAccount? UserAccount { get; set; };
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ public class WiqlBadRequestResponce : BaseRequest
public string? Id { get; set; } = string.Empty;

[JsonProperty("innerException")]
public string? InnerException { get; set; } = string.Empty;
public string InnerException { get; set; } = string.Empty;

[JsonProperty("message")]
public string? Message { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;

[JsonProperty("typeName")]
public string? TypeName { get; set; } = string.Empty;
public string TypeName { get; set; } = string.Empty;

[JsonProperty("typeKey")]
public string? TypeKey { get; set; } = string.Empty;
public string TypeKey { get; set; } = string.Empty;

[JsonProperty("errorCode")]
public int? ErrorCode { get; set; }
public int ErrorCode { get; set; }

[JsonProperty("eventId")]
public int? EventId { get; set; }
public int EventId { get; set; }
}
Loading

0 comments on commit 5c5f12b

Please sign in to comment.