practicekea_backend/microservices/admin
Kishor Tripathy 5802c02ed7 initial push after clone and reading the index file from an external file 2025-10-26 18:39:16 +05:30
..
.config .net9.0 2024-12-02 18:54:34 +05:30
.vscode .net9.0 2024-12-02 18:54:34 +05:30
Content .net9.0 2024-12-02 18:54:34 +05:30
Firebase .net9.0 2024-12-02 18:54:34 +05:30
Properties .net9.0 2024-12-02 18:54:34 +05:30
V1/Controllers .net9.0 2024-12-02 18:54:34 +05:30
Validators .net9.0 2024-12-02 18:54:34 +05:30
bin/net9.0 Converting to net9.0 2025-10-22 18:35:31 +05:30
obj initial push after clone and reading the index file from an external file 2025-10-26 18:39:16 +05:30
API.Admin.csproj Converting to net9.0 2025-10-22 18:35:31 +05:30
CustomAuthorizeFilterNew.cs .net9.0 2024-12-02 18:54:34 +05:30
Dockerfile .net9.0 2024-12-02 18:54:34 +05:30
ErrorHandlingMiddleware.cs .net9.0 2024-12-02 18:54:34 +05:30
Program.cs .net9.0 2024-12-02 18:54:34 +05:30
ReadMe.txt .net9.0 2024-12-02 18:54:34 +05:30
Startup.cs .net9.0 2024-12-02 18:54:34 +05:30
SwaggerConfigurationOptions.cs .net9.0 2024-12-02 18:54:34 +05:30
SwaggerDefaultValues.cs .net9.0 2024-12-02 18:54:34 +05:30
admin.sln .net9.0 2024-12-02 18:54:34 +05:30
appresponsemessages.json .net9.0 2024-12-02 18:54:34 +05:30
appsettings.Development.json .net9.0 2024-12-02 18:54:34 +05:30
appsettings.json .net9.0 2024-12-02 18:54:34 +05:30
global.json Converting to net9.0 2025-10-22 18:35:31 +05:30
web.config .net9.0 2024-12-02 18:54:34 +05:30

ReadMe.txt

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Server=68.71.130.74,1533;Database=odiproj1_oa;Integrated Security=False;user id=oa;password=OdiOdi@1234;
================================================================================================
How to sync DB to model
-Scaffold-DbContext "Server=68.71.130.74,1533;Database=odiproj1_oa;User ID=oa;Password=OdiOdi@1234;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -force
OnlineAssessmentContext.cs - 
	odiproj1_oa to be replaced by OnlineAssessmentContext
	delete the constructor
	delete connection string
	update the namespace

How to Build CRUD REST APIs with ASP.NET Core 3.1 and Entity Framework Core, Create JWT Tokens, and Secure APIs

https://www.syncfusion.com/blogs/post/how-to-build-crud-rest-apis-with-asp-net-core-3-1-and-entity-framework-core-create-jwt-tokens-and-secure-apis.aspx
================================================================================================

Install necessary NuGet packages
================================
Add the following NuGet packages to work with SQL Server database and scaffolding, and run the following commands in Package Manager Console (Click Tools -> NuGet Package Manager ->  Package Manager Console).

This package helps generate controllers and views.
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 3.1.0


This package helps create database context and model classes from the database.
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.1.0


Database provider allows Entity Framework Core to work with SQL Server.
Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 3.1.0


It provides support for creating and validating a JWT token.
Install-Package System.IdentityModel.Tokens.Jwt -Version 5.6.0

This is the middleware that enables an ASP.NET Core application to receive a bearer token in the request pipeline.
Install-Package Microsoft.AspNetCore.Authentication.JwtBearer -Version 3.1.0

================================================================================================
Configuring and Using Swagger UI in ASP.NET Core Web API
https://www.code-maze.com/swagger-ui-asp-net-core-web-api/

Install-Package Swashbuckle.AspNetCore -version 5.4.1


================================================================================================


================================================================================================
Enabling CORS In ASP.NET Core API Applications
https://www.c-sharpcorner.com/article/enabling-cors-in-asp-net-core-api-application/

What is CORS?
 
Cross-Origin Resource Sharing (CORS) manages the cross-origin requests. Unlike same-origin policy, CORS allows making a request from one origin to another. CORS allows the servers to specify who can access the resource on the server from outside.
 
The origin is made up of three parts - the protocol, host, and the port number.
 
This is in continuation of my last article (create RESTful API using ASP.NET Core with Entity Framework Core) so I highly recommend you to go through my previous article for the basic set up of an ASP.NET Core application.
 
Cross Domain call
 
Before enabling the CORS, lets see how the cross-domain call is restricted. Lets create an ASP.NET Core web application.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enabling CORS in ASP.NET Core
https://code-maze.com/enabling-cors-in-asp-net-core/

What Is the Same-Origin policy?
The Same-origin policy states that a Web browser will only allow communication between two URLs if they belong to the same origin. That is, the client app (https://example.com) cannot communicate with the server app (https://example.net) as they belong to a different origin. This policy exists to isolate potentially malicious scripts from harming other documents on the web


What Is CORS?
But there are some cases where Cross-Domain scripting is desired and the idea of the open web makes it compelling.

Cross-Origin Resource Sharing is a mechanism to bypass the Same-Origin policy of a Web browser. Specifically, a server app uses additional HTTP headers to tell a browser that it is fine to load documents (from its origin) in a few selected client apps (of different origin).



Install-Package Microsoft.AspNetCore.Cors -Version 2.2.0


================================================================================================
=====================================================
https://www.codementor.io/@zedotech/how-to-using-automapper-on-asp-net-core-3-0-via-dependencyinjection-zq497lzsq

Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection -Version 7.0.0

================================================================================================
=====================================================


https://thecodebuzz.com/jsonexception-possible-object-cycle-detected-object-depth/



=====================================================
Fluent Validation in ASP.NET Core 3.1
=====================================================
https://nodogmablog.bryanhogan.net/2020/02/fluent-validation-in-asp-net-core-3-1/
https://www.codewithmukesh.com/blog/fluent-validation-aspnet-core/

 Install-Package FluentValidation.AspNetCore.


=====================================================
 Get Response Message From Config File In .NET Core Web API
 https://www.c-sharpcorner.com/article/get-response-message-from-config-file-in-net-core-web-api/

=========================================================================================================================================================================================================================================================================
Setting up Serilog in ASP.NET Core 3
https://www.nuget.org/packages/Serilog.AspNetCore/3.1.0

https://nblumhardt.com/2019/10/serilog-in-aspnetcore-3/

Install-Package Serilog.AspNetCore -Version 3.1.0

=========================================================================================================================================================================================================================================================================

Microservice Architecture in ASP.NET Core with API Gateway

Microservice Arcihtecture is an architecture where the application itself is divided into various components, with each component serving a particular purpose


Introduction to Ocelot API Gateway
Ocelot is an Open Source API Gateway for the .NET/Core Platform. What is does is simple. It cunifies multiple microservices so that the client does not have to worry about the location of each and every Microservice. Ocelot API Gateway transforms the Incoming HTTP Request from the client and forward it to an appropriate Microservice.

Ocelot is widely used by Microsft and other tech-giants as well for Microservice Management. The latest version of Ocelot targets ASP.NET Core 3.1 and is not suitable for .NET Framework Applications. It will be as easy and installing the Ocelot package to your API Gateway project and setting up a JSON Configuration file that states the upstream and downstream routes.

Upstream and Downstream are 2 terms that you have to be clear with. Upstream Request is the Request sent by the Client to the API Gateway. Downstream request is the request sent to the Microservice by the API Gateway. All these are from the perspective of the API Gateway. Lets see a small Diagram to understand this concept better.

https://www.codewithmukesh.com/blog/microservice-architecture-in-aspnet-core/



#############################################################
# SECURITY
https://www.youtube.com/watch?v=l56YLbAVAfo&t=794s
##############################################################
AshProgHelp - Programming Help

->  Install-Package Microsoft.IdentityModel.Tokens (6.7.1)
->  Install-Package System.IdentityModel.Tokens.Jwt (5.6.0)
->  Install-Package Microsoft.AspNetCore.Authentication.JwtBearer(3.1.0)


https://aspnetcore.readthedocs.io/en/stable/security/authorization/policies.html#security-authorization-policies-based

https://devblogs.microsoft.com/aspnet/jwt-validation-and-authorization-in-asp-net-core/

====================================================================================================================================================================================================================
REST API versioning with ASP.NET Core

https://dev.to/99darshan/restful-web-api-versioning-with-asp-net-core-1e8g

Install-Package Microsoft.AspNetCore.Mvc.Versioning
Install-Package Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer

https://github.com/microsoft/aspnet-api-versioning/blob/master/samples/aspnetcore/SwaggerSample/Startup.cs

====================================================================================================================================================================================================================
Scaffold-DbContext “Server=SUVRAM-004\SQLEXPRESS2014;Database=OnlineAssessment;Integrated Security=True;user id=sa;password=maa@1234;” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
====================================================================================================================================================================================================================
Scaffold-DbContext “Server=TSLC0750\SQLEXPRESS;Database=Quiz;Integrated Security=True;user id=sa;password=maa@1234;” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Scaffold-DbContext “Server=TSLC0750\SQLEXPRESS;Database=Quiz;Integrated Security=True;user id=sa;password=maa@1234;” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables Quiz_Countries
Scaffold-DbContext "Server=TSLC0750\SQLEXPRESS_2014;Database=Quiz;Persist Security Info=False;User ID=sa;Password=elaw@1234;" Microsoft.EntityFrameworkCore.SqlServer  -Tables "Quiz_PasswordReset","Quiz_ContactLog" -context TempContext -ContextDir ".\Models" -OutputDir "Models" -force -DataAnnotations -UseDatabaseNames
====================================================================================================================================================================================================================

I wish there were a built-in way to add entities and update an existing context, but there doesn't seem to be. I overcame this by using the --context option in the package manager console and just gave it a temporary name, e.g. --context TempContext. This worked and generated the new table and the temp context. Then I just copied the public virtual DbSet<NewEntityType> NewEntityType { get; set; } property and the modelBuilder.Entity<NewEntityType>(entity => block from the OnModelCreating method in the temp context to my existing one. After that, I deleted the temp context. It's pretty straightforward.

It provides support for creating and validating a JWT token.
Install-Package IdentityModel.Tokens.Jwt -Version 5.6.0

This is the middleware that enables an ASP.NET Core application to receive a bearer token in the request pipeline.
Install-Package Microsoft.AspNetCore.Authentication.JwtBearer -Version 2.1.1


======================================================
S3 Bucket
======================================================
awss3credentials - this file should be in the current directory of the project where its deployed


Repository Pattern:
====================
https://medium.com/net-core/repository-pattern-implementation-in-asp-net-core-21e01c6664d7
https://github.com/kilicars/AspNetCoreRepositoryPattern