Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the DTOs so we return only what is needed. #378

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Handler(IUnitOfWork unitOfWork) : IRequestHandler<Command, Result>
public async Task<Result> Handle(Command request, CancellationToken cancellationToken)
{
var participant = await unitOfWork.DbContext.Participants
.FindAsync([request.IncomingTransfer.Participant.Id], cancellationToken);
.FindAsync([request.IncomingTransfer.ParticipantId], cancellationToken);

var transfer = await unitOfWork.DbContext.ParticipantIncomingTransferQueue
.FindAsync([request.IncomingTransfer.Id], cancellationToken);
Expand Down
11 changes: 9 additions & 2 deletions src/Application/Features/Transfers/DTOs/IncomingTransferDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ namespace Cfo.Cats.Application.Features.Transfers.DTOs;
public class IncomingTransferDto
{
public required Guid Id { get; set; }
public required ParticipantDto Participant { get; set; }


public required string ParticipantFullName { get; set; }
public required string ParticipantId { get; set; }

//public required ParticipantDto Participant { get; set; }
public string? FromContractId { get; set; }
public string? ToContractId { get; set; }
public required LocationDto FromLocation { get; set; }
Expand All @@ -20,7 +25,9 @@ class Mapper : Profile
{
public Mapper()
{
CreateMap<ParticipantIncomingTransferQueueEntry, IncomingTransferDto>();
CreateMap<ParticipantIncomingTransferQueueEntry, IncomingTransferDto>()
.ForMember(p => p.ParticipantId, options => options.MapFrom(src => src.ParticipantId))
.ForMember(p => p.ParticipantFullName, options => options.MapFrom(src => src.Participant!.FirstName + " " + src.Participant!.LastName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ namespace Cfo.Cats.Application.Features.Transfers.DTOs;
public class OutgoingTransferDto
{
public required Guid Id { get; set; }
public required ParticipantDto Participant { get; set; }
public string? FromContractId { get; set; }
public string? ToContractId { get; set; }
public required LocationDto FromLocation { get; set; }
public required LocationDto ToLocation { get; set; }
public required DateTime MoveOccured { get; set; }
public required TransferLocationType TransferType { get; set; }

public required string ParticipantId { get; set; }
public required string ParticipantFullName { get; set; }

class Mapper : Profile
{
public Mapper()
{
CreateMap<ParticipantOutgoingTransferQueueEntry, OutgoingTransferDto>();
CreateMap<ParticipantOutgoingTransferQueueEntry, OutgoingTransferDto>()
.ForMember(t => t.ParticipantId, options => options.MapFrom(source => source.ParticipantId))
.ForMember(t => t.ParticipantFullName, options => options.MapFrom(source => source.Participant!.FirstName + " " + source.Participant.LastName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

var owner = await GetNewMediator().Send(new GetOwnerByParticipantId.Query()
{
ParticipantId = Model.IncomingTransfer.Participant.Id
ParticipantId = Model.IncomingTransfer.ParticipantId
});

if (owner is { Succeeded: true, Data: not null })
Expand Down
10 changes: 5 additions & 5 deletions src/Server.UI/Pages/Transfers/Transfers.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<RowTemplate>
<MudTd DataLabel="Participant">
<div class="d-flex flex-column">
<MudText Typo="Typo.body2">@context.Participant.FullName</MudText>
<MudText Typo="Typo.body2">@context.Participant.Id</MudText>
<MudText Typo="Typo.body2">@context.ParticipantFullName</MudText>
<MudText Typo="Typo.body2">@context.ParticipantId</MudText>
</div>
</MudTd>
<MudTd DataLabel="Occurred">
Expand Down Expand Up @@ -67,8 +67,8 @@
<RowTemplate>
<MudTd DataLabel="Participant">
<div class="d-flex flex-column">
<MudText Typo="Typo.body2">@context.Participant.FullName</MudText>
<MudText Typo="Typo.body2">@context.Participant.Id</MudText>
<MudText Typo="Typo.body2">@context.ParticipantFullName</MudText>
<MudText Typo="Typo.body2">@context.ParticipantId</MudText>
</div>
</MudTd>
<MudTd DataLabel="Occurred">
Expand Down Expand Up @@ -154,6 +154,6 @@
}
}

private void View(OutgoingTransferDto transfer) => Navigation.NavigateTo($"/pages/participants/{transfer.Participant.Id}");
private void View(OutgoingTransferDto transfer) => Navigation.NavigateTo($"/pages/participants/{transfer.ParticipantId}");

}
Loading