Add in the middle ware and Fallbackcontroller.
This commit is contained in:
@@ -25,7 +25,9 @@ namespace CarParkValidationAPI.Authorization
|
|||||||
if (userId != null)
|
if (userId != null)
|
||||||
{
|
{
|
||||||
// attach user to context on successful jwt validation
|
// attach user to context on successful jwt validation
|
||||||
context.Items["User"] = userService.GetById(userId.Value);
|
//here to put in the real user
|
||||||
|
//TODO if you want to add information for User
|
||||||
|
// context.Items["User"] = userService.GetById(userId.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _next(context);
|
await _next(context);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CarParkValidationAPI.Controllers
|
||||||
|
{
|
||||||
|
public class FallbackController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return PhysicalFile(Path.Combine(Directory.GetCurrentDirectory(),
|
||||||
|
"wwwroot", "index.html"), "text/HTML");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,6 @@ namespace CarParkValidationAPI.Datas
|
|||||||
public DbSet<AdminUser> AdminUsers { get; set; }
|
public DbSet<AdminUser> AdminUsers { get; set; }
|
||||||
public DbSet<ValidationPoint> Validations { get; set; }
|
public DbSet<ValidationPoint> Validations { get; set; }
|
||||||
public DbSet<ConcessionValidation> ConcessionValidations { get; set; }
|
public DbSet<ConcessionValidation> ConcessionValidations { get; set; }
|
||||||
|
|
||||||
public DbSet<ConcessionType> ConcessionTypes { get; set; }
|
public DbSet<ConcessionType> ConcessionTypes { get; set; }
|
||||||
private readonly IConfiguration Configuration;
|
private readonly IConfiguration Configuration;
|
||||||
private IOptions<AppSettings> _appSettings;
|
private IOptions<AppSettings> _appSettings;
|
||||||
@@ -32,17 +31,14 @@ namespace CarParkValidationAPI.Datas
|
|||||||
{
|
{
|
||||||
modelBuilder.Entity<ValidationPoint>().ToTable("ValidationPoint");
|
modelBuilder.Entity<ValidationPoint>().ToTable("ValidationPoint");
|
||||||
modelBuilder.Entity<ConcessionValidation>().ToTable("ConcessionValidation");
|
modelBuilder.Entity<ConcessionValidation>().ToTable("ConcessionValidation");
|
||||||
|
|
||||||
modelBuilder.Entity<ConcessionType>().ToTable("ConcessionType");
|
modelBuilder.Entity<ConcessionType>().ToTable("ConcessionType");
|
||||||
modelBuilder.Entity<AdminUser>().ToTable("AdminUser");
|
modelBuilder.Entity<AdminUser>().ToTable("AdminUser");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
{
|
{
|
||||||
// in memory database used for simplicity, change to a real db for production applications
|
// in memory database used for simplicity, change to a real db for production applications
|
||||||
// options.UseInMemoryDatabase("TestDb");
|
// options.UseInMemoryDatabase("TestDb");
|
||||||
|
|
||||||
options.UseSqlServer(_appSettings.Value.SQLConnectionString);
|
options.UseSqlServer(_appSettings.Value.SQLConnectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +92,6 @@ namespace CarParkValidationAPI.Datas
|
|||||||
myobj = reader["StaffEmail"];
|
myobj = reader["StaffEmail"];
|
||||||
if (myobj != System.DBNull.Value)
|
if (myobj != System.DBNull.Value)
|
||||||
item.StaffEmail = (string) myobj;
|
item.StaffEmail = (string) myobj;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
myobj = reader["ValidationPointID"];
|
myobj = reader["ValidationPointID"];
|
||||||
if (myobj != System.DBNull.Value)
|
if (myobj != System.DBNull.Value)
|
||||||
@@ -145,11 +140,58 @@ namespace CarParkValidationAPI.Datas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<int>> SelectCheckConcessionValidationAsync(DateTime fromDate, string concessionCard, string staffLinkNo)
|
||||||
|
{
|
||||||
|
var pfromDate = new SqlParameter
|
||||||
|
{
|
||||||
|
ParameterName = "FromDate",
|
||||||
|
Value = fromDate.Date,
|
||||||
|
};
|
||||||
|
|
||||||
|
var pStaffLink = new SqlParameter
|
||||||
|
{
|
||||||
|
ParameterName = "StaffLinkNo",
|
||||||
|
Value = staffLinkNo,
|
||||||
|
};
|
||||||
|
|
||||||
|
var pConcessionCard = new SqlParameter
|
||||||
|
{
|
||||||
|
ParameterName = "ConcessionCard",
|
||||||
|
Value = concessionCard,
|
||||||
|
};
|
||||||
|
|
||||||
|
ConcessionValidationExtDto item;
|
||||||
|
List<int> result = new List<int>();
|
||||||
|
object myobj;
|
||||||
|
int id;
|
||||||
|
using (var command = this.Database.GetDbConnection().CreateCommand())
|
||||||
|
{
|
||||||
|
command.CommandType = CommandType.StoredProcedure;
|
||||||
|
command.CommandText = ("capv_CheckConValidation_Sel");
|
||||||
|
command.Parameters.Add(pfromDate);
|
||||||
|
command.Parameters.Add(pStaffLink);
|
||||||
|
command.Parameters.Add(pConcessionCard);
|
||||||
|
this.Database.OpenConnection();
|
||||||
|
using (DbDataReader reader = await command.ExecuteReaderAsync())
|
||||||
|
{
|
||||||
|
while (await reader.ReadAsync())
|
||||||
|
{
|
||||||
|
myobj = reader["ValidationID"];
|
||||||
|
if (myobj != System.DBNull.Value)
|
||||||
|
{
|
||||||
|
id = (int)myobj;
|
||||||
|
result.Add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<ConcessionValidationExtDto>> SelectConcessionValidationByDate(bool activeOnly, DateTime fromDate, DateTime toDate)
|
public async Task<List<ConcessionValidationExtDto>> SelectConcessionValidationByDate(bool activeOnly, DateTime fromDate, DateTime toDate)
|
||||||
{
|
{
|
||||||
var pfromDate = new SqlParameter
|
var pfromDate = new SqlParameter
|
||||||
@@ -157,8 +199,6 @@ namespace CarParkValidationAPI.Datas
|
|||||||
ParameterName = "fromDate",
|
ParameterName = "fromDate",
|
||||||
Value = fromDate.Date
|
Value = fromDate.Date
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var pToDate = new SqlParameter
|
var pToDate = new SqlParameter
|
||||||
{
|
{
|
||||||
ParameterName = "toDate",
|
ParameterName = "toDate",
|
||||||
@@ -183,9 +223,7 @@ namespace CarParkValidationAPI.Datas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,8 +61,8 @@ namespace CarParkValidationAPI.Repository
|
|||||||
sl.SetCellValue(row, col++, "ConcessionType");
|
sl.SetCellValue(row, col++, "ConcessionType");
|
||||||
sl.SetCellValue(row, col++, "Validation Piont");
|
sl.SetCellValue(row, col++, "Validation Piont");
|
||||||
sl.SetCellValue(row, col++, "StaffLink No");
|
sl.SetCellValue(row, col++, "StaffLink No");
|
||||||
sl.SetCellValue(row, col++, "Staff first name");
|
sl.SetCellValue(row, col++, "Staff First name");
|
||||||
sl.SetCellValue(row, col++, "Staff last name");
|
sl.SetCellValue(row, col++, "Staff Last name");
|
||||||
sl.SetCellValue(row, col++, "Staff Email");
|
sl.SetCellValue(row, col++, "Staff Email");
|
||||||
sl.FreezePanes(row, col - 1); //frozen the row.
|
sl.FreezePanes(row, col - 1); //frozen the row.
|
||||||
//wrap text on is concession Expiry
|
//wrap text on is concession Expiry
|
||||||
|
|||||||
@@ -159,6 +159,42 @@ namespace CarParkValidationAPI.Repository
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ResultModel<int>> CheckConcessionValidationStaffLinkNoAsync(string staffLinkNo, string concessionCard, DateTime currentDate)
|
public async Task<ResultModel<int>> CheckConcessionValidationStaffLinkNoAsync(string staffLinkNo, string concessionCard, DateTime currentDate)
|
||||||
|
{
|
||||||
|
int statuscode = 1;
|
||||||
|
int result = 1;
|
||||||
|
string message = "warning you already add concession card on this date!";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var anyRecord = await _context.SelectCheckConcessionValidationAsync(currentDate.ToLocalTime().Date, concessionCard, staffLinkNo);
|
||||||
|
|
||||||
|
if (anyRecord.Count > 0)
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = 1; //test
|
||||||
|
message = "test OK just one time";
|
||||||
|
}
|
||||||
|
statuscode = 1;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = "Error " + ex.ToString();
|
||||||
|
statuscode = 0;
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResultModel<int>()
|
||||||
|
{
|
||||||
|
Data = result,
|
||||||
|
StatusCode = statuscode,
|
||||||
|
Message = message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<ResultModel<int>> CheckConcessionValidationStaffLinkNoAsync_old(string staffLinkNo, string concessionCard, DateTime currentDate)
|
||||||
{
|
{
|
||||||
int statuscode = 1;
|
int statuscode = 1;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|||||||
@@ -131,9 +131,17 @@ namespace CarParkValidationAPI
|
|||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
/* if add angular under wwwroot then two line below needed*/
|
||||||
|
/***************************/
|
||||||
|
// app.UseDefaultFiles(); //it will use index.html <------------------
|
||||||
|
// app.UseStaticFiles(); //it for angular <-------------------------
|
||||||
|
|
||||||
|
/***************************/
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
|
// endpoints.MapFallbackToController("Index", "Fallback"); //<------------------ put angular in wwwroot.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"AppSettings": {
|
"AppSettings": {
|
||||||
"Secret": "Nepean Blue Mountain Super Secret SIGN AND VERIFY JWT TOKENS, BEARER TOKEN USE WHEN CALLING THIS API.",
|
"Secret": "Nepean Blue Mountain Super Secret SIGN AND VERIFY JWT TOKENS, BEARER TOKEN USE WHEN CALLING THIS API.",
|
||||||
"SQLConnectionString": "Server=NEPHICT-040931L;Initial Catalog=CarParkValidation;Persist Security Info=False;User ID=bids_admin;Password=Password4BI;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;",
|
"SQLConnectionString": "Server=NEPHMDB-SQL007;Initial Catalog=CarParkValidation;Persist Security Info=False;User ID=bids_admin;Password=Password4BI;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;",
|
||||||
"LDAPPath": "LDAP://ldap.nswhealth.net:389/OU=Accounts,DC=nswhealth,DC=net",
|
"LDAPPath": "LDAP://ldap.nswhealth.net:389/OU=Accounts,DC=nswhealth,DC=net",
|
||||||
"LDAPUser": "SRV-NBMS-BIDSPMS",
|
"LDAPUser": "SRV-NBMS-BIDSPMS",
|
||||||
"LDAPPassword": "42Ytp2AE3nN16eBoyia86UZH6",
|
"LDAPPassword": "42Ytp2AE3nN16eBoyia86UZH6",
|
||||||
@@ -17,7 +17,8 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
/*Positive~1
|
/*
|
||||||
|
"SQLConnectionString": "Server=NEPHICT-040931L;Initial Catalog=CarParkValidation;Persist Security Info=False;User ID=bids_admin;Password=Password4BI;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;",
|
||||||
user id=bids_admin;password=Password4BI;
|
user id=bids_admin;password=Password4BI;
|
||||||
Server=tcp:10.60.207.82,1433;
|
Server=tcp:10.60.207.82,1433;
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"AppSettings": {
|
"AppSettings": {
|
||||||
"Secret": "Nepean Blue Mountain Super Secret SIGN AND VERIFY JWT TOKENS, BEARER TOKEN USE WHEN CALLING THIS API.",
|
"Secret": "Nepean Blue Mountain Super Secret SIGN AND VERIFY JWT TOKENS, BEARER TOKEN USE WHEN CALLING THIS API.",
|
||||||
|
"SQLConnectionString": "Server=NEPHMDB-SQL007;Initial Catalog=CarParkValidation;Persist Security Info=False;User ID=bids_admin;Password=Password4BI;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;",
|
||||||
"LDAPPath": "LDAP://ldap.nswhealth.net:389/OU=Accounts,DC=nswhealth,DC=net",
|
"LDAPPath": "LDAP://ldap.nswhealth.net:389/OU=Accounts,DC=nswhealth,DC=net",
|
||||||
"LDAPUser": "SRV-NBMS-BIDSPMS",
|
"LDAPUser": "SRV-NBMS-BIDSPMS",
|
||||||
"LDAPPassword": "42Ytp2AE3nN16eBoyia86UZH6",
|
"LDAPPassword": "42Ytp2AE3nN16eBoyia86UZH6",
|
||||||
|
|||||||
Reference in New Issue
Block a user