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.Types/Serials/SerialService.cs

62 lines
2.1 KiB

using System.Collections.Immutable;
using Connected.Entities;
using Connected.ServiceModel;
using Connected.Services;
using Ops = Connected.Logistics.Types.Serials.SerialOps;
namespace Connected.Logistics.Types.Serials;
/// <inheritdoc cref="ISerialService"/>
internal sealed class SerialService : EntityService<long>, ISerialService
{
/// <summary>
/// Create a new <see cref="SerialService"/> service.
/// </summary>
/// <param name="context">The context which serves as a DI scope.</param>
public SerialService(IContext context) : base(context)
{
}
/// <inheritdoc cref="ISerialService.Delete(PrimaryKeyArgs{long})"/>
public async Task Delete(PrimaryKeyArgs<long> args)
{
await Invoke(GetOperation<Ops.Delete>(), args);
}
/// <inheritdoc cref="ISerialService.Insert(InsertSerialArgs)"/>
public async Task<long> Insert(InsertSerialArgs args)
{
return await Invoke(GetOperation<Ops.Insert>(), args);
}
/// <inheritdoc cref="ISerialService.Query(QueryArgs?)"/>
public async Task<ImmutableList<ISerial>> Query(QueryArgs? args)
{
return await Invoke(GetOperation<Ops.Query>(), args ?? QueryArgs.Default);
}
/// <inheritdoc cref="ISerialService.Query(PrimaryKeyListArgs{long})"/>
public async Task<ImmutableList<ISerial>> Query(PrimaryKeyListArgs<long> args)
{
return await Invoke(GetOperation<Ops.Lookup>(), args);
}
/// <inheritdoc cref="ISerialService.Select(PrimaryKeyArgs{long})"/>
public async Task<ISerial?> Select(PrimaryKeyArgs<long> args)
{
return await Invoke(GetOperation<Ops.Select>(), args);
}
/// <inheritdoc cref="ISerialService.Select(SelectSerialArgs)"/>
public async Task<ISerial?> Select(SelectSerialArgs args)
{
return await Invoke(GetOperation<Ops.SelectByValue>(), args);
}
/// <inheritdoc cref="ISerialService.Update(UpdateSerialArgs)"/>
public async Task Update(UpdateSerialArgs args)
{
await Invoke(GetOperation<Ops.Update>(), args);
}
/// <inheritdoc cref="ISerialService.Patch(PatchArgs{long})"/>
public async Task Patch(PatchArgs<long> args)
{
if (await Select(args.Id) is not Serial entity)
return;
await Update(args.Patch<UpdateSerialArgs, Serial>(entity));
}
}