-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mediatr request for getting delivery channel policy collections, …
…remove redundant exception definition from DeliveryChannelPolicyDataValidator
- Loading branch information
Showing
3 changed files
with
68 additions
and
32 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
62 changes: 62 additions & 0 deletions
62
...protagonist/API/Features/DeliveryChannels/Requests/GetDeliveryChannelPolicyCollections.cs
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 DLCS.Model.Assets; | ||
using DLCS.Model.Policies; | ||
using DLCS.Repository; | ||
using Hydra.Collections; | ||
using MediatR; | ||
|
||
namespace API.Features.DeliveryChannels.Requests; | ||
|
||
public class GetDeliveryChannelPolicyCollections: IRequest<HydraCollection<HydraNestedCollection<DeliveryChannelPolicy>>> | ||
{ | ||
public int CustomerId { get; } | ||
public string BaseUrl { get; } | ||
public string JsonLdId { get; } | ||
|
||
public GetDeliveryChannelPolicyCollections(int customerId, string baseUrl, string jsonLdId) | ||
{ | ||
CustomerId = customerId; | ||
BaseUrl = baseUrl; | ||
JsonLdId = jsonLdId; | ||
} | ||
} | ||
|
||
public class GetDeliveryChannelPolicyCollectionsHandler : IRequestHandler<GetDeliveryChannelPolicyCollections, HydraCollection<HydraNestedCollection<DeliveryChannelPolicy>>> | ||
{ | ||
private readonly DlcsContext dbContext; | ||
|
||
public GetDeliveryChannelPolicyCollectionsHandler(DlcsContext dbContext) | ||
{ | ||
this.dbContext = dbContext; | ||
} | ||
|
||
public async Task<HydraCollection<HydraNestedCollection<DeliveryChannelPolicy>>> Handle(GetDeliveryChannelPolicyCollections request, CancellationToken cancellationToken) | ||
{ | ||
var policyCollections = new HydraNestedCollection<DeliveryChannelPolicy>[] | ||
{ | ||
new(request.BaseUrl, AssetDeliveryChannels.Image) | ||
{ | ||
Title = "Policies for IIIF Image service delivery", | ||
}, | ||
new(request.BaseUrl, AssetDeliveryChannels.Thumbnails) | ||
{ | ||
Title = "Policies for thumbnails as IIIF Image Services", | ||
}, | ||
new(request.BaseUrl, AssetDeliveryChannels.Timebased) | ||
{ | ||
Title = "Policies for Audio and Video delivery", | ||
}, | ||
new(request.BaseUrl, AssetDeliveryChannels.File) | ||
{ | ||
Title = "Policies for File delivery", | ||
} | ||
}; | ||
|
||
return new HydraCollection<HydraNestedCollection<DeliveryChannelPolicy>>() | ||
{ | ||
WithContext = true, | ||
Members = policyCollections, | ||
TotalItems = policyCollections.Length, | ||
Id = request.JsonLdId, | ||
}; | ||
} | ||
} |
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