Cheranga / Demo.Mini.Products.Api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Products API

Context

To provide a Products API to use for automation.

Using the API in your local environment

  • Install Docker Desktop.
  • Install Azure Storage Explorer.
  • Open a command prompt and run the below command to download and run Azurite as a container in detached mode.
docker run -d -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
  • Open Azure Storage Explorer and create below. This table and queues are needed for the API to function.
    • registrations table.
    • registrations queue.
    • update-registrations queue.

Features

Register product

  • Validate request.
  • Handling failures.
  • Publishing domain event to Azure storage queue.
  • Save data in Azure table storage.

Change location of a product

  • Validate request.
  • Handling failures.
  • Publishing domain event to Azure storage queue.
  • Save data in Azure table storage.

Get product by id

  • Validate request.
  • Handling failures.

Get all products

  • Returns all the products.

Authentication and Authorization

  • Integrating with Azure AD for authentication and authorization.

Logging

  • Using Serilog for structured logging.

Versioning

  • Support for default and specific versioning.

CI/CD

  • Using GHA for CI/CD pipelines.
  • Using Azure Bicep for cloud resources deployment.

API Documentation

  • Including comprehensive API documentation using Swagger.

Automation tests

  • Creating an integration test suite.

References

public static async ValueTask<ChangeLocationRequest> BindAsync(
    HttpContext context,
    ParameterInfo _
)
    {
        var category = context.GetRouteValue(nameof(Category))?.ToString();
        var productId = context.GetRouteValue(nameof(Id))?.ToString();
        var record = await context.Request.Body.ToModel<ChangeLocationRequest>() with
        {
            Category = category ?? string.Empty,
            Id = productId ?? string.Empty
        };
    
        return record;
    }
}

About


Languages

Language:C# 100.0%