You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Logistics/Logistics.Types/Packaging/PackingService.cs

57 lines
1.4 KiB

2 years ago
using System.Collections.Immutable;
using Connected.Entities;
using Connected.ServiceModel;
using Connected.Services;
using Ops = Logistics.Types.Packaging.PackingOps;
namespace Logistics.Types.Packaging;
internal sealed class PackingService : EntityService<int>, IPackingService
{
public PackingService(IContext context) : base(context)
{
}
public async Task Delete(PrimaryKeyArgs<int> args)
{
await Invoke(GetOperation<Ops.Delete>(), args);
}
public async Task<int> Insert(InsertPackingArgs args)
{
return await Invoke(GetOperation<Ops.Insert>(), args);
}
public async Task Patch(PatchArgs<int> args)
{
if (await Select(args.Id) is not Packing entity)
return;
await Update(args.Patch<UpdatePackingArgs, Packing>(entity));
}
public async Task<ImmutableList<IPacking>> Query(QueryArgs? args)
{
return await Invoke(GetOperation<Ops.Query>(), args ?? QueryArgs.Default);
}
public async Task<ImmutableList<IPacking>> Query(PrimaryKeyListArgs<int> args)
{
return await Invoke(GetOperation<Ops.Lookup>(), args);
}
public async Task<IPacking?> Select(PrimaryKeyArgs<int> args)
{
return await Invoke(GetOperation<Ops.Select>(), args);
}
public async Task<IPacking?> Select(SelectPackingArgs args)
{
return await Invoke(GetOperation<Ops.SelectByEan>(), args);
}
public async Task Update(UpdatePackingArgs args)
{
await Invoke(GetOperation<Ops.Update>(), args);
}
}