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/Connected.Logistics.Documents/Receive/ReceiveDocumentService.cs

83 lines
3.2 KiB

using System.Collections.Immutable;
using Connected.Common.Documents;
using Connected.Entities;
using Connected.ServiceModel;
using ItemOps = Connected.Logistics.Documents.Receive.ReceiveDocumentItemOps;
using Ops = Connected.Logistics.Documents.Receive.ReceiveDocumentOps;
namespace Connected.Logistics.Documents.Receive;
/// <inheritdoc cref="IReceiveDocumentService"/>
internal sealed class ReceiveDocumentService : DocumentService<int, long>, IReceiveDocumentService
{
/// <summary>
/// Create a new <see cref="ReceiveDocument"/> instance
/// </summary>
/// <param name="context">The DI scope used by this instance.</param>
public ReceiveDocumentService(IContext context) : base(context)
{
}
/// <inheritdoc cref="IReceiveDocumentService.Delete(PrimaryKeyArgs{int})"/>
public async Task Delete(PrimaryKeyArgs<int> args)
{
await Invoke(GetOperation<Ops.Delete>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.DeleteItem(PrimaryKeyArgs{long})"/>
public async Task DeleteItem(PrimaryKeyArgs<long> args)
{
await Invoke(GetOperation<ItemOps.Delete>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.Insert(InsertReceiveDocumentArgs)"/>
public async Task<int> Insert(InsertReceiveDocumentArgs args)
{
return await Invoke(GetOperation<Ops.Insert>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.InsertItem(InsertReceiveItemArgs)"/>
public async Task<long> InsertItem(InsertReceiveItemArgs args)
{
return await Invoke(GetOperation<ItemOps.Insert>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.Patch(PatchArgs{int})"/>
public async Task Patch(PatchArgs<int> args)
{
if (await Select(args.Id) is not ReceiveDocument entity)
return;
await Update(args.Patch<UpdateReceiveDocumentArgs, ReceiveDocument>(entity));
}
/// <inheritdoc cref="IReceiveDocumentService.Query(QueryArgs?)"/>
public async Task<ImmutableList<IReceiveDocument>> Query(QueryArgs? args)
{
return await Invoke(GetOperation<Ops.Query>(), args ?? QueryArgs.Default);
}
/// <inheritdoc cref="IReceiveDocumentService.QueryItems(PrimaryKeyArgs{int})"/>
public async Task<ImmutableList<IReceiveItem>> QueryItems(PrimaryKeyArgs<int> args)
{
return await Invoke(GetOperation<ItemOps.Query>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.Select(PrimaryKeyArgs{int})"/>
public async Task<IReceiveDocument?> Select(PrimaryKeyArgs<int> args)
{
return await Invoke(GetOperation<Ops.Select>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.SelectItem(PrimaryKeyArgs{long})"/>
public async Task<IReceiveItem?> SelectItem(PrimaryKeyArgs<long> args)
{
return await Invoke(GetOperation<ItemOps.Select>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.SelectItem(SelectReceiveItemArgs)"/>
public async Task<IReceiveItem?> SelectItem(SelectReceiveItemArgs args)
{
return await Invoke(GetOperation<ItemOps.SelectByEntity>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.Update(UpdateReceiveDocumentArgs)"/>
public async Task Update(UpdateReceiveDocumentArgs args)
{
await Invoke(GetOperation<Ops.Update>(), args);
}
/// <inheritdoc cref="IReceiveDocumentService.UpdateItem(UpdateReceiveItemArgs)"/>
public async Task UpdateItem(UpdateReceiveItemArgs args)
{
await Invoke(GetOperation<ItemOps.Update>(), args);
}
}