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.Common.Types/Common.Types/TaxRates/TaxRateService.cs

94 lines
3.3 KiB

2 years ago
using Common.Types.Security;
using Connected.ServiceModel;
using Connected.Services;
using Connected.Services.Annotations;
using System.Collections.Immutable;
namespace Common.Types.TaxRates;
/// <summary>
/// The implementation class for <see cref="ITaxRateService"/> service.
/// </summary>
internal sealed class TaxRateService : EntityService<int>, ITaxRateService
{
public TaxRateService(IContext context) : base(context)
{
}
/// <summary>
/// Perorfms a lookup on <see cref="ITaxRate"/> records based on a specified
/// set of ids.
/// </summary>
/// <param name="e">The list of ids for which records should be returned.</param>
/// <returns>The list if <see cref="ITaxRate"/> records.</returns>
[ServiceAuthorization(Claims.Read)]
public async Task<ImmutableList<ITaxRate>?> Query(PrimaryKeyListArgs<int> e)
{
return await Invoke(GetOperation<TaxRateOps.Lookup>(), e);
}
/// <summary>
/// Queries the entire <see cref="ITaxRate"/> entity set.
/// </summary>
/// <returns>The list of all <see cref="ITaxRate"/> entities.</returns>
[ServiceAuthorization(Claims.Read)]
public async Task<ImmutableList<ITaxRate>?> Query(QueryArgs? args)
{
return await Invoke(GetOperation<TaxRateOps.Query>(), args ?? QueryArgs.NoPaging);
}
/// <summary>
/// Searches for the first <see cref="ITaxRate"/> entity which matches
/// the specified arguments.
/// </summary>
/// <param name="args">The arguments representing search criteria.</param>
/// <returns>The first <see cref="ITaxRate"/> entity which matches the
/// criteria, <code>null</code> otherwise.</returns>
[ServiceAuthorization(Claims.Read)]
public async Task<ITaxRate?> Select(TaxRateArgs args)
{
return await Invoke(GetOperation<TaxRateOps.SelectByRate>(), args);
}
/// <summary>
/// Selects the <see cref="ITaxRate"/> for the specified id.
/// </summary>
/// <param name="args">The id for which a record will
/// be returned.</param>
/// <returns>The <see cref="ITaxRate"/> entity with the specified id,
/// <code>null</code> otherwise.</returns>
[ServiceAuthorization(Claims.Read)]
public async Task<ITaxRate?> Select(PrimaryKeyArgs<int> args)
{
return await Invoke(GetOperation<TaxRateOps.Select>(), args);
}
/// <summary>
/// Permanently deletes an <see cref="ITaxRate"/> entity with
/// the specified id.
/// </summary>
/// <remarks>
/// This operation can be rejected by an <see cref="IDataProtectionMiddleware{TArgs}"/>
/// middleware.
/// </remarks>
/// <param name="args">The id of the entity which will be deleted.</param>
[ServiceAuthorization(Claims.Delete)]
public async Task Delete(PrimaryKeyArgs<int> args)
{
await Invoke(GetOperation<TaxRateOps.Delete>(), args);
}
/// <summary>
/// Inserts a new <see cref="ITaxRate"/> entity into the system.
/// </summary>
/// <param name="args">The values representing a new entity.</param>
/// <returns>An id of the newly inserted entity.</returns>
[ServiceAuthorization(Claims.Add)]
public async Task<int> Insert(InsertTaxRateArgs args)
{
return await Invoke(GetOperation<TaxRateOps.Insert>(), args);
}
/// <summary>
/// Updates an existing <see cref="ITaxRate"/> entity.
/// </summary>
/// <param name="args">The arguments representing a changed values.</param>
[ServiceAuthorization(Claims.Modify)]
public async Task Update(UpdateTaxRateArgs args)
{
await Invoke(GetOperation<TaxRateOps.Update>(), args);
}
}