Skip to main content

Posts

Showing posts with the label Dotnet6

A Demo On .NET6 API Sending Email Using SendGrid NuGet Package

In this article, we are going to implement a sample in .NET6 Web API to send emails using the SendGrid Nuget Package. Create A .Net6 Web API Project: Let's create a .Net6 Web API sample application 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. CLI command dotnet new webapi -o Your_Project_Name SendGrid: SendGrid is a third-party email provider from which we can deal with 'send', and 'receive' operations of email to our application. SendGrid SMTP(Simple Mail Transfer Protocol) provider for email transfer. SendGrid also provides SendGrid .Net NuGet package that provides easy configuration to any .NET applications. So to use the SendGrid SMTP we need 'Auth Key', 'From Email', so let's register into the SendGrid. The following are the steps to register and

Part-5 A CRUD Operation Demo With .NET6 Web API | SQL Database | Angular13

The main objectives of this article are: Implement HTTP Post Create Action Method In API Implement HTTP Post API Call At Student Service In Angular App Student Component Implement Logic To Create A New Student Implement HTTP Put Update Action Method In API Implement HTTP Put API Call-In Student Service Student Component Implement Logic To Update An Existing Student Implement HTTP Delete Action Method In API Implement HTTP Delete API Call At Student Service Student Component Implement Logic To Delete Student Implement HTTP Post Create Action Method In API: Let's try to create a new student record into our database by implementing the HTTP Post Action Method(or Create action method.) in our 'StudentController'. API_Project/Controllers/StudentController.cs: [HttpPost] public async Task<IActionResult> Post(Student.Api.Data.Entities.Student payload) { _myWorldDbContext.Student.Add(payload); await _myWorldDbContext.SaveChangesAsync(); return Ok(payload); } (Line: 1

Part-4 A CRUD Operation Demo With .NET6 Web API | SQL Database | Angular13

The main objectives of this article: Create StudentController In API Project HTTP Get Action Method In API Project(Read Operation) Create Student Component In Angular Application. Create Student Model In Angular Application. Add A Student Service And Invoke GET Student API In Angular Application. Bind API Response In Student Component In Angular Application. Fix Cross-Origin Issue. Create StudentController In API Project: A controller is an entity or class that contains logical methods or function that gets executed for an HTTP request from the clients. So let's create the 'StudentController' in API Project. API_Project/Controllers/StudentController.cs: using Microsoft.AspNetCore.Mvc; using Student.Api.Data; namespace Student.Api.Controllers; [ApiController] [Route("[controller]")] public class StudentController: ControllerBase { private readonly MyWorldDbContext _myWorldDbContext; public StudentController(MyWorldDbContext myWorldDbContext) {

Part-3 A CRUD Operation Demo With .NET6 Web API | SQL Database | Angular13

The main objectives of this article are: .NET6 Web API Install .NET6 SDK Create A .NET6 Web API Application. Entity Framework Core Install Entity Framework Core NuGet SQL Connectionstring Setup Entity Framework Core DatabaseContext. .NET6 Web API: Web API is a framework for building an HTTP service that can be accessed from any client like browser, mobile devices, and desktop apps. In simple terminology API(Application Programming Interface) means an interface module that contains a programming function that can be requested via HTTP calls to save or fetch the data for their respective clients. Some of the key characteristics of  API: Supports HTTP verbs like 'GET', 'POST', 'PUT', 'DELETE', etc. Supports default responses like 'XML' and 'JSON'. Also can define custom responses. Supports self-hosting or individual hosting, so that all different kinds of apps can consume it. Authentication and Authorization are easy to implement. The id