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.
57 lines
2.0 KiB
57 lines
2.0 KiB
using System.Collections.Immutable;
|
|
using Connected.Entities;
|
|
using Connected.ServiceModel;
|
|
using Connected.Services;
|
|
using Ops = Connected.Logistics.Types.Warehouses.WarehouseOps;
|
|
|
|
namespace Connected.Logistics.Types.Warehouses;
|
|
/// <inheritdoc cref="IWarehouseService"/>
|
|
internal sealed class WarehouseService : EntityService<int>, IWarehouseService
|
|
{
|
|
/// <summary>
|
|
/// Creates a new <see cref="WarehouseService"/> instance.
|
|
/// </summary>
|
|
/// <param name="context">The context acting as a DI scope.</param>
|
|
public WarehouseService(IContext context) : base(context)
|
|
{
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Delete(PrimaryKeyArgs{int})"/>
|
|
public async Task Delete(PrimaryKeyArgs<int> args)
|
|
{
|
|
await Invoke(GetOperation<Ops.Delete>(), args);
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Insert(InsertWarehouseArgs)"/>
|
|
public async Task<int> Insert(InsertWarehouseArgs args)
|
|
{
|
|
return await Invoke(GetOperation<Ops.Insert>(), args);
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Query(QueryArgs?)"/>
|
|
public async Task<ImmutableList<IWarehouse>> Query(QueryArgs? args)
|
|
{
|
|
return await Invoke(GetOperation<Ops.Query>(), args ?? QueryArgs.Default);
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Query(PrimaryKeyListArgs{int})"/>
|
|
public async Task<ImmutableList<IWarehouse>> Query(PrimaryKeyListArgs<int> args)
|
|
{
|
|
return await Invoke(GetOperation<Ops.Lookup>(), args);
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Select(PrimaryKeyArgs{int})"/>
|
|
public async Task<IWarehouse?> Select(PrimaryKeyArgs<int> args)
|
|
{
|
|
return await Invoke(GetOperation<Ops.Select>(), args);
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Update(UpdateWarehouseArgs)"/>
|
|
public async Task Update(UpdateWarehouseArgs args)
|
|
{
|
|
await Invoke(GetOperation<Ops.Update>(), args);
|
|
}
|
|
/// <inheritdoc cref="IWarehouseService.Patch(PatchArgs{int})"/>
|
|
public async Task Patch(PatchArgs<int> args)
|
|
{
|
|
if (await Select(args.Id) is not Warehouse entity)
|
|
return;
|
|
|
|
await Update(args.Patch<UpdateWarehouseArgs, Warehouse>(entity));
|
|
}
|
|
}
|