Thank you for purchasing my script. If you have any questions that are beyond the scope of this help file, feel free to email me.
For Admin access, Username:admin@2020 Password:admin@2020
For User access, Username:user@2020 Password:user@2020
"ConnectionStrings": { "ApiConnStringMssql": "data source=Sangib-PC;initial catalog=AdminDB; persist security info=True;Integrated Security=SSPI;", "ApiConnStringMysql": "server=localhost;port=3306;database=AdminDB;user=root;", "ApiConnStringOracle": "Data Source=(DESCRIPTION=(ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orclpdb)));User Id=root;Password=root;", "ApiConnStringSqlite": "Data Source=AdminDB.db;", "ApiConnStringPostgreSql": "Server=127.0.0.1;Port=5432;Database=AdminDB; User Id=postgres;Password=postgres;" }
Then open Startup.cs file, On ConfigureServices method you will see five AppDbContextPool for five Connection Strings that already have on appsettings.json file. Un-Comment your required one and keep other four as commented.Have a look to the below code.I only un-comment the Mysql portion because i used Mysql DB here.
public void ConfigureServices(IServiceCollection services) { //Sql Server Connection String /* services.AddDbContextPool<AppDbContext>(opt => opt.UseSqlServer (Configuration.GetConnectionString("ApiConnStringMssql"))); */ //Mysql Connection String services.AddDbContextPool<AppDbContext>(opt=>opt.UseMySql (Configuration.GetConnectionString("ApiConnStringMysql"))); //Sqlite Connection String /* services.AddDbContextPool<AppDbContext>(opt=>opt.UseSqlite (Configuration.GetConnectionString("ApiConnStringSqlite"))); */ //PostgreSql Connection String /* services.AddDbContextPool<AppDbContext>(opt=>opt.UseNpgsql (Configuration.GetConnectionString("ApiConnStringPostgreSql"))); */ //Oracle Connection String /* services.AddDbContextPool<AppDbContext>(opt=>opt.UseOracle (Configuration.GetConnectionString("ApiConnStringOracle"))); */
->dotnet ef migrations add <MigrationName>
->dotnet ef database update
->dotnet run
string GenerateJwtToken(UserInfo userInfo)
{
var securityKey=new SymmetricSecurityKey(Encoding.UTF8.GetBytes
(_config["Jwt:SecretKey"]));
var credentials = new SigningCredentials(securityKey,
SecurityAlgorithms.HmacSha256);
var claims = new[]
{
new Claim(JwtRegisteredClaimNames.Sub, userInfo.UserId.ToString()),
new Claim("fullName", userInfo.FullName.ToString()),
new Claim("role",userInfo.RoleName),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
};
var token = new JwtSecurityToken(
issuer: _config["Jwt:Issuer"],
audience: _config["Jwt:Audience"],
claims: claims,
expires: DateTime.Now.AddMinutes(180),
signingCredentials: credentials
);
return new JwtSecurityTokenHandler().WriteToken(token);
}
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Seed();//use this for Sql server,Mysql,Sqlite and PostgreSql //modelBuilder.SeedOracle();//use this only for Oracle }
{ "Logging": { "Debug": { "LogLevel": { "Default": "Warning", "AdminClient.Controllers.ErrorController": "Warning", "AdminClient.Controllers.HomeController": "Warning", "Microsoft": "Warning" } }, "LogLevel": { "Default": "Trace", "AdminClient.Controllers.ErrorController": "Trace", "AdminClient.Controllers.HomeController": "Trace", "Microsoft": "Warning" } }, "AllowedHosts": "*", "WebAPIBaseUrl": "http://localhost:5001" }
public void ConfigureServices(IServiceCollection services) { services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(60); }); services.AddControllersWithViews(); }
Once again, thank you so much for purchasing this script. As I said at the beginning, I'd be glad to help you if you have any questions relating to this script. I'll do my best to assist. If you have a more general question relating to the scripts on Codecanyon, you might consider visiting the forums and asking your question in the "Item Discussion" section.
Sangib Kumar Saha