Skip to main content

Posts

Showing posts with the label Caching & more ๐Ÿงบ

๐Ÿš€Master User Authentication in .NET 8 Web API Email Confirmation, Password Reset, 2FA & Lockout with JWT & Identity๐Ÿ”

Part 6️⃣ - Create UnitTest | ๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

  Unit Testing OrdersController in .NET 8 Web API with FakeItEasy and FluentAssertions - OrdersControllerTest.cs In this tutorial, we explore how to unit test the OrdersController in a .NET 8 Web API project. By leveraging the power of FakeItEasy for mocking dependencies and FluentAssertions for writing expressive assertions, we ensure that our controller behaves as expected. We'll cover various scenarios to validate the controller's actions, including retrieving client orders and order details. Here’s what we’ll cover: 1. Setting Up the Test Environment We'll start by configuring our test environment. Using FakeItEasy , we create mock instances of our service dependencies, and we initialize the OrdersController with these mocks. 2. Testing GetClientOrders Action Valid Client ID : We'll verify that when a valid client ID is provided, the controller returns an OK result with the expected list of orders. No Orders Found : We'll handle the scenario where no orders

Part 5️⃣ - Ocelot Gateway API๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

Ocelot Configuration File - ocelot.json This configuration file sets up routes for an API Gateway using Ocelot. The gateway manages requests for three main services: Authentication, Product, and Order APIs. Here's a detailed description of each section: Authentication Routes Path : /api/authentication/{everything} Host : localhost:5000 Methods : GET, POST, PUT, DELETE Rate Limiting : Allows 1 request per 10 seconds. Product Routes Get All Products Path : /api/products Host : localhost:5001 Method : GET Caching : 60 seconds with custom header eCommerce-Caching-Control . Get Product By ID Path : /api/products/{id} Host : localhost:5001 Method : GET Caching : 60 seconds with custom header eCommerce-Caching-Control . Modify Products Path : /api/products/{everything} Host : localhost:5001 Methods : POST, PUT, DELETE Authentication : Bearer token required. Order Routes Get All Orders Path : /api/orders Host : localhost:5002 Method : GET Caching : 20 seconds with custom header eCommerce-C

Part 4️⃣ - JWT Authentication API |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

Entity Description - AppUser AppUser Class Description The AppUser class represents a user in the application, encapsulating various properties related to user identity, contact information, and roles. Here’s a detailed breakdown of each property: Id Type : int Description : A unique identifier for the user. Name Type : string? Description : The user's name. It is nullable, allowing the possibility of no name being provided. TelephoneNumber Type : string? Description : The user's telephone number. It is nullable. Address Type : string? Description : The user's physical address. It is nullable. Email Type : string? Description : The user's email address. It is nullable. Password Type : string? Description : The user's password for authentication. It is nullable. Role Type : string? Description : The role assigned to the user (e.g., Admin, User). It is nullable. DateRegistered Type : DateTime Description : The date and time when the user registered. It defaults to th

Part 3️⃣ - Order API |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

Domain Layer Order Entity The Order entity represents an order within the e-commerce system. It captures essential details related to a customer's purchase and is a core component of the Order API. Properties Id : Type: int Description: Unique identifier for the order. This serves as the primary key in the database. ProductId : Type: int Description: Identifier for the product associated with the order. This links the order to a specific product in the Product API. ClientId : Type: int Description: Identifier for the client who placed the order. This associates the order with a specific customer. PurchaseQuantity : Type: int Description: The quantity of the product purchased in the order. OrderedDate : Type: DateTime Description: The date and time when the order was placed. Defaults to the current UTC time when the order is created. Summary The Order entity is a crucial part of the Order API, encapsulating the data required to manage and process customer orders. It link

Part 2️⃣ - Product API |๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ

๐Ÿ›’ Build .NET 8 eCommerce Microservice ๐Ÿš€with API Gateway, Rate Limiting, Caching & more ๐Ÿงบ - [Part 2️⃣] Product Description This code defines the Product class within the ProductApi.Domain.Entities namespace. The Product class represents a product entity with properties commonly associated with products in an e-commerce application. Features Id : Represents the unique identifier for the product. It is an integer property and serves as the primary key for the product entity. Name : Represents the name of the product. It is a nullable string property, allowing the product name to be optional. Price : Represents the price of the product. It is a decimal property, ensuring accurate representation of the product's cost, including fractions of currency units. Quantity : Represents the quantity of the product available in stock. It is an integer property, indicating the number of units of the product that are available. Usage Data Representation : The Product class is used to rep