-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update data model Rename RevisionContainer -> Container Rename Reviewer -> TagReviewer
- Loading branch information
Showing
107 changed files
with
1,494 additions
and
2,037 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace datasheetapi.Adapters; | ||
public static class ContainerAdapter | ||
{ | ||
public static ContainerDto? ToDtoOrNull(this Container? revisionContainer) | ||
{ | ||
if (revisionContainer is null) { return null; } | ||
return revisionContainer.ToDto(); | ||
} | ||
|
||
private static ContainerDto ToDto(this Container revisionContainer) | ||
{ | ||
|
||
return new ContainerDto | ||
{ | ||
Id = revisionContainer.Id, | ||
ContainerName = revisionContainer.ContainerName, | ||
RevisionNumber = revisionContainer.RevisionNumber, | ||
ContainerDate = revisionContainer.ContainerDate, | ||
ContractId = revisionContainer.ContractId, | ||
TagNos = revisionContainer.Tags.Select(t => t.TagNo).ToList() | ||
}; | ||
} | ||
|
||
public static List<ContainerDto> ToDto(this List<Container>? revisionContainers) | ||
{ | ||
if (revisionContainers is null) { return new List<ContainerDto>(); } | ||
return revisionContainers.Select(ToDto).ToList(); | ||
} | ||
|
||
public static Container? ToModelOrNull(this ContainerDto? revisionContainerDto) | ||
{ | ||
if (revisionContainerDto is null) { return null; } | ||
return revisionContainerDto.ToModel(); | ||
} | ||
|
||
private static Container ToModel(this ContainerDto revisionContainerDto) | ||
{ | ||
return new Container | ||
{ | ||
Id = revisionContainerDto.Id, | ||
ContainerName = revisionContainerDto.ContainerName, | ||
RevisionNumber = revisionContainerDto.RevisionNumber, | ||
ContainerDate = revisionContainerDto.ContainerDate, | ||
ContractId = revisionContainerDto.ContractId, | ||
}; | ||
} | ||
|
||
public static List<Container> ToModel(this List<ContainerDto>? revisionContainerDtos) | ||
{ | ||
if (revisionContainerDtos is null) { return new List<Container>(); } | ||
return revisionContainerDtos.Select(ToModel).ToList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using datasheetapi.Dtos.ContainerReview; | ||
|
||
namespace datasheetapi.Adapters; | ||
public static class ContainerReviewAdapter | ||
{ | ||
public static ContainerReviewDto ToDto(this ContainerReview revisionContainerReview) | ||
{ | ||
return new ContainerReviewDto | ||
{ | ||
Id = revisionContainerReview.Id, | ||
State = MapContainerReviewStateModelToDto(revisionContainerReview.State), | ||
CommentResponsible = revisionContainerReview.CommentResponsible, | ||
ContainerId = revisionContainerReview.ContainerId, | ||
}; | ||
} | ||
|
||
public static List<ContainerReviewDto> ToDto(this List<ContainerReview>? revisionContainerReviews) | ||
{ | ||
if (revisionContainerReviews is null) { return new List<ContainerReviewDto>(); } | ||
return revisionContainerReviews.Select(ToDto).ToList(); | ||
} | ||
|
||
public static ContainerReview ToModel(this ContainerReviewDto revisionContainerReviewDto) | ||
{ | ||
return new ContainerReview | ||
{ | ||
Id = revisionContainerReviewDto.Id, | ||
State = MapContainerReviewStateDtoToModel(revisionContainerReviewDto.State), | ||
CommentResponsible = revisionContainerReviewDto.CommentResponsible, | ||
ContainerId = revisionContainerReviewDto.ContainerId, | ||
}; | ||
} | ||
|
||
public static ContainerReview ToModel(this CreateContainerReviewDto dto) | ||
{ | ||
return new ContainerReview | ||
{ | ||
ContainerId = dto.RevisionContainerId, | ||
State = MapContainerReviewStateDtoToModel(dto.State), | ||
}; | ||
} | ||
|
||
public static ContainerReviewStateEnumDto MapContainerReviewStateModelToDto(ContainerReviewStateEnum state) | ||
{ | ||
return state switch | ||
{ | ||
ContainerReviewStateEnum.Active => ContainerReviewStateEnumDto.Active, | ||
ContainerReviewStateEnum.SentToContractor => ContainerReviewStateEnumDto.SentToContractor, | ||
_ => throw new ArgumentOutOfRangeException(nameof(state), $"Unknown state: {state}"), | ||
}; | ||
} | ||
|
||
public static ContainerReviewStateEnum MapContainerReviewStateDtoToModel(ContainerReviewStateEnumDto state) | ||
{ | ||
return state switch | ||
{ | ||
ContainerReviewStateEnumDto.Active => ContainerReviewStateEnum.Active, | ||
ContainerReviewStateEnumDto.SentToContractor => ContainerReviewStateEnum.SentToContractor, | ||
_ => throw new ArgumentOutOfRangeException(nameof(state), $"Unknown state: {state}"), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using datasheetapi.Dtos.ContainerReview; | ||
using datasheetapi.Dtos.ContainerReviewer; | ||
using datasheetapi.Dtos.TagReviewer; | ||
|
||
namespace datasheetapi.Adapters; | ||
|
||
public static class ContainerReviewerAdapter | ||
{ | ||
public static ContainerReviewer ToModel(this CreateContainerReviewerDto dto) | ||
{ | ||
return new ContainerReviewer | ||
{ | ||
UserId = dto.UserId, | ||
State = ContainerReviewerStateEnum.Open, | ||
TagReviewers = dto.TagReviewers?.ToModel() ?? new List<TagReviewer>() | ||
}; | ||
} | ||
|
||
public static ContainerReviewerDto ToDto(this ContainerReviewer model, Dictionary<Guid, string> userIdNameMap) | ||
{ | ||
return new ContainerReviewerDto | ||
{ | ||
Id = model.Id, | ||
ContainerReviewId = model.ContainerReviewId, | ||
State = MapContainerReviewStateModelToDto(model.State), | ||
UserId = model.UserId, | ||
TagReviewers = model.TagReviewers.ToDto(userIdNameMap), | ||
}; | ||
} | ||
|
||
public static List<ContainerReviewerDto> ToDto(this List<ContainerReviewer> model, | ||
Dictionary<Guid, string> userIdNameMap) | ||
{ | ||
return model.Select(m => m.ToDto(userIdNameMap)).ToList(); | ||
} | ||
|
||
public static ContainerReviewerStateEnumDto MapContainerReviewStateModelToDto(ContainerReviewerStateEnum state) | ||
{ | ||
return state switch | ||
{ | ||
ContainerReviewerStateEnum.Open => ContainerReviewerStateEnumDto.Open, | ||
ContainerReviewerStateEnum.Abandoned => ContainerReviewerStateEnumDto.Abandoned, | ||
ContainerReviewerStateEnum.Complete => ContainerReviewerStateEnumDto.Complete, | ||
_ => throw new ArgumentOutOfRangeException(nameof(state), $"Unknown state: {state}"), | ||
}; | ||
} | ||
|
||
public static ContainerReviewerStateEnum MapContainerReviewStateDtoToModel(ContainerReviewerStateEnumDto state) | ||
{ | ||
return state switch | ||
{ | ||
ContainerReviewerStateEnumDto.Open => ContainerReviewerStateEnum.Open, | ||
ContainerReviewerStateEnumDto.Abandoned => ContainerReviewerStateEnum.Abandoned, | ||
ContainerReviewerStateEnumDto.Complete => ContainerReviewerStateEnum.Complete, | ||
_ => throw new ArgumentOutOfRangeException(nameof(state), $"Unknown state: {state}"), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.