Skip to main content

Posts

Showing posts from February, 2022

A Small Demo On Item Sorting In Angular(V13) Using Angular Material(V13) Drag&Drop

In this article, we will implement a small angular application about item sorting using the angular material drag&drop. Key Notes About Angular Material Drag&Drop: Let's know about a few key things on angular material drag&drop like: DragDropModule load from the library '@angular/cdk/drag-drop' The 'cdkDrag' attribute makes an element draggable. The 'cdkDropList' attribute on an element that surrounds a set of 'cdkDrag' elements groups the draggable into a reorderable collection. So it creates a boundary of the region for dragging. The 'cdkDropListDropped' is an event fired after dipping the item. Create An Angular Application: To accomplish our demo let's create a sample angular application. Command To Install Angular CLI: npm install -g @angular/cli Command To Create Angular App: ng new your_app_name Now let's install angular material into our application. Command To Install Angular Material: ng add @angular/mate

An Overview On Running Background Job Or Task In Asp.NetCore Application[.NET 6]

In this article, we are going to understand about Hosting a Background Task or Job inside of an Asp.NetCore application. Hosted BackGround Task Workflow: To create a background job or task in an Asp.Net core application then the class should inherit the 'Microsoft.Extension.Hosting.BackgroundService'. The 'Microsoft.Extension.Hosting.BackgroundService' is an abstract class that contains overridable methods like 'StopAsync', 'ExecuteAsync'. StopAsync -  gets executed once our normal Asp.Net core application stops. ExecuteAsync - gets executed after the 'StartAsync' method and it is in an abstract method which means it must be implemented in our background job class. Here we can write logic like to run a particular job at regular intervals until the Asp.Net core application stops running. When To Use? : So Hosted Background job can be used in cases like: 1. If our Asp.Net core generates some files and we have to delete them at regular interval

Unit Testing Asp.NetCore Web API Using xUnit[.NET6]

In this article, we are going to write test cases to an Asp.NetCore Web API(.NET6) application using the xUnit. xUnit For .NET: The xUnit for .Net is a free, open-source, community-focused unit testing tool for .NET applications. By default .Net also provides a xUnit project template to implement test cases. Unit test cases build upon the 'AAA' formula that means 'Arrange', 'Act' and 'Assert' Arrange - Declaring variables, objects, instantiating mocks, etc. Act - Calling or invoking the method that needs to be tested. Assert - The assert ensures that code behaves as expected means yielding expected output. Create An API And Unit Test Projects: Let's create a .Net6 Web API and xUnit sample applications to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any.Net6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. Create a fo

A CRUD Operation Demo With Blazor WebAssembly(.NET6) + Strawberry Shake GraphQL Client + MudBlazor UI + GraphQL API

In this article, we are to implement CRUD operation in Blazor WebAssembly(.NET6) by consuming GraphQL endpoint with help of  'Strawberry Shake'(Graphql Client Library). GraphQL Endpoint: In this demo, we have to consume the GraphQL endpoint from our Blazor WebAssembly application. Source code for .Net6 GraphQL CRUD operations. The article explains about creating .NET 6 GraphQL CRUD operations The video explains about creating .NET6 GraphQL CRUD operations Strawberry Shake: Strawberry shake is an open-source GraphQL client that is compliant with the newest GraphQL draft spec, which makes Strawberry Shake compatible with all GraphQL compliant servers like Hot Chocolate, Apollo Server, GraphQL Java, and various other servers out there. Strawberry Shake will generate the schema of GraphQL Server which will help to invoke the GraphQL endpoint very easily. Strawberry Shake CLI Tool: Strawberry shake CLI needs to be configured because CLI will help us to generate the GraphQL clie