Skip to main content

arolariu.Backend.Domain.Invoices.Endpoints

arolariu.Backend.Domain.Invoices

arolariu.Backend.Domain.Invoices.Endpoints Namespace

Classes

InvoiceEndpoints Class

Extension host for registering all invoice and merchant related HTTP endpoints (routing surface for the Invoices bounded context).

public static class InvoiceEndpoints

Inheritance System.Object 🡒 InvoiceEndpoints

Remarks

Composition: Split across partial class files: core mapping (InvoiceEndpoints.cs), handler implementations (InvoiceEndpoints.Handlers.cs), response / request DTO mappings (InvoiceEndpoints.Mappings.cs) and metadata enhancements (InvoiceEndpoints.Metadata.cs).

Versioning: Current semantic package surface version stored in SemanticVersioning; the external public REST route uses a URI version segment (rest/v1) decoupled from internal semantic version (allows internal additive changes without immediate URI bump).

Security: Authentication / authorization policies are applied in handler implementations or via metadata partial. This class centralizes grouping only.

Telemetry: Activity scopes started for helper methods (RetrieveUserIdentifierClaimFromPrincipal, IsPrincipalSuperUser) to ensure consistent trace spans.

Extensibility: New route groups SHOULD be appended inside MapInvoiceEndpoints(this IEndpointRouteBuilder); consider new versioned group (rest/v2) for breaking changes.

Thread-safety: Static initialization only; no mutable shared state beyond constants.

Fields

InvoiceEndpoints.EndpointNameTag Field

The OpenAPI tag name for Invoice Management endpoints.

private const string EndpointNameTag = "Invoice Management System v1.0.0";

Field Value

System.String

InvoiceEndpoints.SemanticVersioning Field

The semantic version of the Invoice Management API surface.

private const string SemanticVersioning = "1.0.0";

Field Value

System.String

Methods

InvoiceEndpoints.AddInvoiceToMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, MerchantInvoicesRequestDto) Method

Adds one or more invoices to a specific merchant.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> AddInvoiceToMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.MerchantInvoicesRequestDto invoiceIdentifiers);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant.

invoiceIdentifiers MerchantInvoicesRequestDto

The list of invoice identifiers to add.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the addition.

InvoiceEndpoints.AddMerchantToInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, AddMerchantToInvoiceRequestDto) Method

Adds or updates the merchant associated with an invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> AddMerchantToInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.AddMerchantToInvoiceRequestDto merchantDto);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to which the merchant will be added.

merchantDto AddMerchantToInvoiceRequestDto

The merchant DTO containing the merchant data to associate with the invoice.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the addition.

InvoiceEndpoints.AddProductToInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, CreateProductRequestDto) Method

Adds a product to a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> AddProductToInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.CreateProductRequestDto product);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to which the product will be added.

product CreateProductRequestDto

The product data to add to the invoice.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the addition.

InvoiceEndpoints.AnalyzeInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, AnalyzeInvoiceRequestDto) Method

Analyzes a specific invoice using AI/ML services.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> AnalyzeInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.AnalyzeInvoiceRequestDto options);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling analysis logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to analyze.

options AnalyzeInvoiceRequestDto

The options for the analysis (e.g., detailed, basic).

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the analysis result.

InvoiceEndpoints.CreateInvoiceScanAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, CreateInvoiceScanRequestDto) Method

Creates a new scan for a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> CreateInvoiceScanAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.CreateInvoiceScanRequestDto invoiceScanDto);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to which the scan will be added.

invoiceScanDto CreateInvoiceScanRequestDto

The invoice scan data to be created.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the creation.

InvoiceEndpoints.CreateNewInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, CreateInvoiceRequestDto) Method

Creates a new invoice in the system.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> CreateNewInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, arolariu.Backend.Domain.Invoices.DTOs.Requests.CreateInvoiceRequestDto invoiceDto);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

invoiceDto CreateInvoiceRequestDto

The data transfer object containing the details of the invoice to be created.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the result of the creation process.

InvoiceEndpoints.CreateNewMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, CreateMerchantRequestDto) Method

Creates a new merchant in the system.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> CreateNewMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, arolariu.Backend.Domain.Invoices.DTOs.Requests.CreateMerchantRequestDto merchantDto);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

merchantDto CreateMerchantRequestDto

The merchant data transfer object containing the details of the merchant to create.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the created merchant identifier.

InvoiceEndpoints.DeleteInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Deletes a specific invoice by its identifier.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> DeleteInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to delete.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the deletion.

InvoiceEndpoints.DeleteInvoiceMetadataAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, DeleteMetadataRequestDto) Method

Deletes specific metadata keys from a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> DeleteInvoiceMetadataAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.DeleteMetadataRequestDto metadataKeys);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice.

metadataKeys DeleteMetadataRequestDto

The list of metadata keys to remove.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the deletion.

InvoiceEndpoints.DeleteInvoicesAsync(IInvoiceProcessingService, IHttpContextAccessor) Method

Deletes all invoices associated with the authenticated user.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> DeleteInvoicesAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the deletion.

InvoiceEndpoints.DeleteInvoiceScanAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, string) Method

Deletes a specific invoice scan.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> DeleteInvoiceScanAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, string scanLocationField);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice.

scanLocationField System.String

The unique identifier of the scan to delete.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the deletion.

InvoiceEndpoints.DeleteMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Guid) Method

Deletes a specific merchant from the system.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> DeleteMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, System.Guid parentCompanyId);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant to delete.

parentCompanyId System.Guid

The unique identifier of the parent company to validate against.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the deletion.

InvoiceEndpoints.IsPrincipalSuperUser(IHttpContextAccessor) Method

Determines whether the authenticated principal possesses elevated (super user) privileges.

private static bool IsPrincipalSuperUser(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor);

Parameters

httpContextAccessor Microsoft.AspNetCore.Http.IHttpContextAccessor

Accessor exposing the current Microsoft.AspNetCore.Http.HttpContext.

Returns

System.Boolean
true when super user (always true in current stub); will become conditional after implementation.

Remarks

Status: Placeholder implementation returning true; to be replaced with role / claim inspection (e.g. role = "superuser").

Future Implementation Notes: Introduce policy constants, cache high-privilege evaluation, and surface explicit audit logging on positive elevation.

Security: Must be implemented prior to exposing admin-tier endpoint behaviors; current stub risks privilege over-grant if used unsafely.

Context Source: Accesses the authenticated principal through Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext instead of DI parameters.

Telemetry: Activity span added for future diagnostic correlation of elevation checks.

InvoiceEndpoints.MapInvoiceAnalysisEndpoints(this IEndpointRouteBuilder) Method

Registers invoice analysis endpoints (computational enrichment and AI / OCR driven classification).

private static void MapInvoiceAnalysisEndpoints(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder router);

Parameters

router Microsoft.AspNetCore.Routing.IEndpointRouteBuilder

Route builder instance.

Remarks

Operation: Current surface exposes a single POST analyze route performing synchronous orchestration then returning 202 Accepted.

Backlog: Potential evolution to long‑running asynchronous workflow (introduce operation status resource, webhooks or push notifications).

Charging / Billing: Includes 402 PaymentRequired problem mapping placeholder for future usage-based billing enforcement.

Idempotency: Re-analysis overwrites prior enrichment; idempotent only when source inputs have not changed.

InvoiceEndpoints.MapInvoiceEndpoints(this IEndpointRouteBuilder) Method

Registers all invoice, invoice analysis and merchant endpoint groups into the application's routing pipeline.

public static void MapInvoiceEndpoints(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder router);

Parameters

router Microsoft.AspNetCore.Routing.IEndpointRouteBuilder

Endpoint route builder (must be non-null) used during application startup.

Remarks

Grouping Strategy: Consolidates related endpoints under the base path segment rest/v1. Each subgroup (standard invoice, analysis, merchant) is defined in a corresponding partial implementation method (MapStandardInvoiceEndpoints, MapInvoiceAnalysisEndpoints, MapStandardMerchantEndpoints).

Idempotency: Safe to invoke once during startup; repeated invocation would register duplicate endpoints (DO NOT call multiple times).

Versioning Policy: Route segment version (v1) DOES NOT auto-track semantic constant SemanticVersioning; bump URI only on public breaking changes.

Cross-Cutting Concerns: Authentication, authorization, validation, caching, and OpenAPI metadata are applied in handler / metadata partials to keep this method declarative.

InvoiceEndpoints.MapStandardInvoiceEndpoints(this IEndpointRouteBuilder) Method

Registers CRUD + ancillary resource routes for the Invoice aggregate and its owned / associated sub-resources.

private static void MapStandardInvoiceEndpoints(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder router);

Parameters

router Microsoft.AspNetCore.Routing.IEndpointRouteBuilder

Route builder used during startup; MUST NOT be null.

Remarks

Scope: Core invoice lifecycle (create, read single/many, full replace, partial update, delete), product collection management, merchant association, scan (OCR source asset) management and arbitrary metadata dictionary operations.

Design: Separate route declarations from handler implementations to keep a clean composition boundary (OpenAPI metadata, auth policies, media types).

Security: All endpoints require authentication; fine‑grained authorization (roles / ownership) enforced in handler / service layers.

Status Code Policy: Uses:

  • 201 Created for create operations producing new aggregates or sub-resources.
  • 202 Accepted for idempotent mutations that conceptually could become async (update / patch).
  • 204 No Content for destructive operations (delete).
  • 409 Conflict when attempting to create an already existing singular subordinate resource (e.g. scan already present).

OpenAPI: Names each endpoint with handler method name via Microsoft.AspNetCore.Routing.EndpointNameMetadata for consistent client generation keys.

Extensibility: Future concerns (pagination on list endpoints, ETag concurrency, conditional requests) SHOULD extend this mapping with additional metadata (e.g. .WithMetadata(new ResponseCacheAttribute()) or custom filters) rather than modifying handlers.

InvoiceEndpoints.MapStandardMerchantEndpoints(this IEndpointRouteBuilder) Method

Registers merchant aggregate endpoints and cross-aggregate relationship management routes (merchant ↔ invoice, merchant ↔ products via invoices).

private static void MapStandardMerchantEndpoints(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder router);

Parameters

router Microsoft.AspNetCore.Routing.IEndpointRouteBuilder

Route builder used at startup configuration time.

Remarks

Scope: Merchant CRUD plus association / dissociation of invoices and retrieval of transitive product collections.

Consistency: Association endpoints (patch / delete on invoices relationship) maintain bidirectional integrity (merchant reference on invoice and invoice id in merchant’s reference list) in handler layer; future refactor may move to domain service for transactional cohesion.

Performance: Retrieval of products across all merchant invoices performs N invoice reads; future optimization backlog: fan-out query or projection in persistence layer.

Status Codes: Mirrors invoice conventions; PATCH used for additive invoice linkage to avoid misuse of PUT semantics.

InvoiceEndpoints.PatchInvoiceMetadataAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, PatchMetadataRequestDto) Method

Patches the metadata of a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> PatchInvoiceMetadataAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.PatchMetadataRequestDto invoiceMetadataPatch);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice.

invoiceMetadataPatch PatchMetadataRequestDto

The metadata key-value pairs to add or update.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the patch.

InvoiceEndpoints.PatchSpecificInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, PatchInvoiceRequestDto) Method

Patches a specific invoice with partial updates.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> PatchSpecificInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.PatchInvoiceRequestDto invoicePayload);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to patch.

invoicePayload PatchInvoiceRequestDto

The partial invoice data to apply as a patch.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the patched invoice.

InvoiceEndpoints.RemoveInvoiceFromMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, MerchantInvoicesRequestDto) Method

Removes one or more invoices from a specific merchant.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RemoveInvoiceFromMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.MerchantInvoicesRequestDto invoiceIdentifiers);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant.

invoiceIdentifiers MerchantInvoicesRequestDto

The list of invoice identifiers to remove.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the removal.

InvoiceEndpoints.RemoveMerchantFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Removes the merchant associated with a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RemoveMerchantFromInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice from which to remove the merchant.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the removal.

InvoiceEndpoints.RemoveProductFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, DeleteProductRequestDto) Method

Removes a product from a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RemoveProductFromInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.DeleteProductRequestDto productDto);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice from which to remove the product.

productDto DeleteProductRequestDto

The DTO containing the product identifier to remove.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the removal.

InvoiceEndpoints.RetrieveAllInvoicesAsync(IInvoiceProcessingService, IHttpContextAccessor) Method

Retrieves all invoices available to the user.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveAllInvoicesAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the list of invoices.

InvoiceEndpoints.RetrieveAllMerchantsAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves all merchants from the system, optionally filtered by parent company.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveAllMerchantsAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid parentCompanyId);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

parentCompanyId System.Guid

The unique identifier of the parent company to filter merchants by.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing a list of merchants.

InvoiceEndpoints.RetrieveInvoiceMetadataAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves the metadata associated with a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveInvoiceMetadataAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice from which to retrieve metadata.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the invoice metadata.

InvoiceEndpoints.RetrieveInvoiceScansAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves all scans associated with a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveInvoiceScansAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice from which to retrieve scans.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the list of invoice scans.

InvoiceEndpoints.RetrieveInvoicesFromMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves all invoices associated with a specific merchant.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveInvoicesFromMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing a list of invoices.

InvoiceEndpoints.RetrieveMerchantFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves the merchant associated with a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveMerchantFromInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice from which to retrieve the merchant.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the merchant details.

InvoiceEndpoints.RetrieveProductsFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves all products from a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveProductsFromInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice from which to retrieve products.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the list of products.

InvoiceEndpoints.RetrieveProductsFromMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves all products associated with a specific merchant.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveProductsFromMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing a list of products.

InvoiceEndpoints.RetrieveSpecificInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid) Method

Retrieves a specific invoice by its identifier.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveSpecificInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to retrieve.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the retrieved invoice.

InvoiceEndpoints.RetrieveSpecificMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Nullable<Guid>) Method

Retrieves a specific merchant by its identifier.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> RetrieveSpecificMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, System.Nullable<System.Guid> parentCompanyId);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant to retrieve.

parentCompanyId System.Nullable<System.Guid>

The unique identifier of the parent company to validate against.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the retrieved merchant.

InvoiceEndpoints.RetrieveUserIdentifierClaimFromPrincipal(IHttpContextAccessor) Method

Extracts the domain user identifier (GUID) from the current Microsoft.AspNetCore.Http.HttpContext.

private static System.Guid RetrieveUserIdentifierClaimFromPrincipal(Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor);

Parameters

httpContextAccessor Microsoft.AspNetCore.Http.IHttpContextAccessor

Accessor exposing the current Microsoft.AspNetCore.Http.HttpContext.

Returns

System.Guid
Resolved user GUID or Guid.Empty when claim absent / invalid.

Remarks

Expected Claim:userIdentifier claim containing a valid GUID string.

Fallback: Returns Guid.Empty if claim missing or unparsable (will propagate to downstream validation layers which SHOULD reject).

Telemetry: Starts an Activity span for diagnostic correlation of identity resolution.

Context Source: Pulls the System.Security.Claims.ClaimsPrincipal from Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext; when absent, a new empty principal is created to avoid null dereferences.

Performance: Single-pass LINQ search over claim collection; negligible overhead for typical principal sizes.

InvoiceEndpoints.UpdateProductInInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, UpdateProductRequestDto) Method

Updates a product in a specific invoice.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> UpdateProductInInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.UpdateProductRequestDto productInformation);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice containing the product.

productInformation UpdateProductRequestDto

The updated product DTO containing the product identifier and new data.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the update.

InvoiceEndpoints.UpdateSpecificInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, UpdateInvoiceRequestDto) Method

Updates a specific invoice by replacing it entirely.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> UpdateSpecificInvoiceAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.UpdateInvoiceRequestDto invoicePayload);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling invoice logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the invoice to update.

invoicePayload UpdateInvoiceRequestDto

The new invoice data that will replace the existing invoice.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, containing the updated invoice.

InvoiceEndpoints.UpdateSpecificMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, UpdateMerchantRequestDto) Method

Updates a specific merchant in the system.

internal static System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult> UpdateSpecificMerchantAsync(arolariu.Backend.Domain.Invoices.Services.Processing.IInvoiceProcessingService invoiceProcessingService, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContext, System.Guid id, arolariu.Backend.Domain.Invoices.DTOs.Requests.UpdateMerchantRequestDto merchantPayload);

Parameters

invoiceProcessingService IInvoiceProcessingService

The invoice processing service responsible for handling merchant logic.

httpContext Microsoft.AspNetCore.Http.IHttpContextAccessor

The HTTP context accessor for accessing request information.

id System.Guid

The unique identifier of the merchant to update.

merchantPayload UpdateMerchantRequestDto

The updated merchant object.

Returns

System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>
A task representing the asynchronous operation, indicating the result of the update.

// was this page useful?