commit change all folder
This commit is contained in:
@@ -5,13 +5,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.12" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.12.0" />
|
||||
<PackageReference Include="SpreadsheetLight" Version="3.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31515.178
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarParkValidationAPI", "CarParkValidationAPI\CarParkValidationAPI.csproj", "{FCD8F53F-967F-4E66-B42C-DCD0C83B2670}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonAD", "..\..\CommonAD\CommonAD.csproj", "{8FB49AA9-08D8-400E-BA06-250C479A2296}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FCD8F53F-967F-4E66-B42C-DCD0C83B2670}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FCD8F53F-967F-4E66-B42C-DCD0C83B2670}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FCD8F53F-967F-4E66-B42C-DCD0C83B2670}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FCD8F53F-967F-4E66-B42C-DCD0C83B2670}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8FB49AA9-08D8-400E-BA06-250C479A2296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8FB49AA9-08D8-400E-BA06-250C479A2296}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8FB49AA9-08D8-400E-BA06-250C479A2296}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8FB49AA9-08D8-400E-BA06-250C479A2296}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B6C27BFF-4D28-4CB3-954C-F3B6C100B5EC}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,27 @@
|
||||
using AutoMapper;
|
||||
using CarParkValidationAPI.Entities;
|
||||
using CarParkValidationAPI.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarParkValidationAPI.Datas
|
||||
{
|
||||
public class AutoMapping: Profile
|
||||
{
|
||||
public AutoMapping()
|
||||
{
|
||||
CreateMap<ConcessionType, ConcessionTypeDto>()
|
||||
.ForMember( dest => dest.Id, opt => opt.MapFrom(src => src.ConcessionTypeID))
|
||||
.ForMember(dest => dest.Description , opt=> opt.MapFrom(src=> src.ConcessionDesc))
|
||||
.ForMember(dest => dest.Display, opt => opt.MapFrom(src => src.ConcessionDisplay))
|
||||
.ReverseMap();
|
||||
CreateMap<ValidationPoint, ValidationPointDto>()
|
||||
.ForMember(dest => dest.Id , opt => opt.MapFrom(src => src.ValidationPointID))
|
||||
.ForMember(dest => dest.Display, opt => opt.MapFrom(src => src.DisplayName))
|
||||
.ReverseMap();
|
||||
/*etc...*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace CarParkValidationAPI.Interface
|
||||
public interface IAdminUser
|
||||
{
|
||||
Task<ResultModel<List<AdminUserViewDto>>> LoadAdminUserAsync(bool OnlyActive);
|
||||
Task<ResultModel<bool>> CheckAdminUserByStaffLinkNoAsync(string staffLinkNo);
|
||||
Task<ResultModel<int>> SaveAdminUserAsync(AdminUserDto item);
|
||||
Task<ResultModel<AdminUserDto>> LoadAdminUserByIdAsync(int id);
|
||||
Task<ResultModel<bool>> DeleteAdminUserAsync(int id);
|
||||
+12
-5
@@ -60,7 +60,15 @@ namespace CarParkValidationAPI.Repository
|
||||
model.AddedOn = dto.AddedOn;
|
||||
return model;
|
||||
}
|
||||
|
||||
public async Task<ResultModel<bool>> CheckAdminUserByStaffLinkNoAsync(string staffLinkNo)
|
||||
{
|
||||
var list = await _context.AdminUsers.Where(x => x.StafflinkNo == staffLinkNo).ToListAsync();
|
||||
return new ResultModel<bool>()
|
||||
{
|
||||
Data = false,
|
||||
StatusCode = 1
|
||||
};
|
||||
}
|
||||
public async Task<ResultModel<List<AdminUserViewDto>>> LoadAdminUserAsync(bool onlyActive)
|
||||
{
|
||||
/*
|
||||
@@ -89,7 +97,8 @@ namespace CarParkValidationAPI.Repository
|
||||
throw ex;
|
||||
}
|
||||
*/
|
||||
for (int i =0; i < 10; i++)
|
||||
var list = await _context.AdminUsers.Where(x => x.Active == onlyActive).ToListAsync();
|
||||
for (int i =0; i < list.Count; i++)
|
||||
{
|
||||
AdminUserViewDto dto = new AdminUserViewDto();
|
||||
dto.Id = i;
|
||||
@@ -110,7 +119,7 @@ namespace CarParkValidationAPI.Repository
|
||||
public async Task<ResultModel<AdminUserDto>> LoadAdminUserByIdAsync(int id)
|
||||
{
|
||||
AdminUserDto result = null;
|
||||
/*
|
||||
|
||||
try
|
||||
{
|
||||
if (id > 0)
|
||||
@@ -124,8 +133,6 @@ namespace CarParkValidationAPI.Repository
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return new ResultModel<AdminUserDto>()
|
||||
{
|
||||
+52
-6
@@ -119,6 +119,37 @@ namespace CarParkValidationAPI.Repository
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
public async Task<ResultModel<bool>> CheckAdminUserByStaffLinkNoAsync(string staffLinkNo)
|
||||
{
|
||||
bool result = false;
|
||||
int statuscode = 0;
|
||||
string error = "";
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(staffLinkNo))
|
||||
{
|
||||
var list = await _context.AdminUsers.Where( x=> x.StafflinkNo == staffLinkNo).ToListAsync();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
result = true;
|
||||
statuscode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.ToString();
|
||||
statuscode = 0;
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return new ResultModel<bool>()
|
||||
{
|
||||
Data = result,
|
||||
StatusCode = statuscode,
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
public async Task<ResultModel<AdminUserDto>> LoadAdminUserByIdAsync(int id)
|
||||
{
|
||||
AdminUserDto result = null;
|
||||
@@ -162,17 +193,32 @@ namespace CarParkValidationAPI.Repository
|
||||
model.LastModified = DateTime.Now;
|
||||
model.LastModifiedId = _currentUser;
|
||||
await _context.SaveChangesAsync();
|
||||
result = model.UserID;
|
||||
statuscode = 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
model = new AdminUser();
|
||||
model = FillAdminUser(item, model);
|
||||
_context.AdminUsers.Add(model);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
ResultModel<bool> found = await CheckAdminUserByStaffLinkNoAsync(item.StafflinkNo);
|
||||
|
||||
if (!found.Data)
|
||||
{
|
||||
model = new AdminUser();
|
||||
model = FillAdminUser(item, model);
|
||||
_context.AdminUsers.Add(model);
|
||||
await _context.SaveChangesAsync();
|
||||
result = model.UserID;
|
||||
statuscode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = "staff link No '" + item.StafflinkNo + "' already in admin user";
|
||||
statuscode = 0;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
result = model.UserID;
|
||||
statuscode = 1;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
+12
-5
@@ -12,6 +12,7 @@ using CarParkValidationAPI.Datas;
|
||||
using CarParkValidationAPI.Interface;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using AutoMapper;
|
||||
|
||||
namespace CarParkValidationAPI.Repository
|
||||
{
|
||||
@@ -20,12 +21,13 @@ namespace CarParkValidationAPI.Repository
|
||||
private DataContext _context;
|
||||
private string _currentUser = "";
|
||||
private readonly AppSettings _appSettings;
|
||||
|
||||
public ConcessionTypeRepository(
|
||||
private readonly IMapper _mapper;
|
||||
public ConcessionTypeRepository(
|
||||
DataContext context,
|
||||
|
||||
IOptions<AppSettings> appSettings)
|
||||
IMapper mapper,
|
||||
IOptions<AppSettings> appSettings)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_context = context;
|
||||
_appSettings = appSettings.Value;
|
||||
}
|
||||
@@ -57,6 +59,7 @@ namespace CarParkValidationAPI.Repository
|
||||
string error = "";
|
||||
try
|
||||
{
|
||||
/*
|
||||
result = await _context.ConcessionTypes.Select(
|
||||
x => new ConcessionTypeDto()
|
||||
{
|
||||
@@ -65,6 +68,9 @@ namespace CarParkValidationAPI.Repository
|
||||
Display = x.ConcessionDisplay,
|
||||
Active = x.Active
|
||||
}).ToListAsync();
|
||||
*/
|
||||
var olist = await _context.ConcessionTypes.ToListAsync();
|
||||
result = _mapper.Map<List<ConcessionTypeDto>>(olist);
|
||||
statuscode = 1;
|
||||
result.Sort((x, y) => x.Description.CompareTo(y.Description));
|
||||
}
|
||||
@@ -92,7 +98,8 @@ namespace CarParkValidationAPI.Repository
|
||||
try
|
||||
{
|
||||
result = await _context.ConcessionTypes.FindAsync(id);
|
||||
dto = FillConcessionTypeDto(result);
|
||||
dto = _mapper.Map<ConcessionTypeDto>(result);
|
||||
//dto = FillConcessionTypeDto(result);
|
||||
//result = _list.Find(x => x.Id == id);
|
||||
//var dto = await Task.Run(() => result);
|
||||
statuscode = 1;
|
||||
+16
-16
@@ -89,10 +89,10 @@ namespace CarParkValidationAPI.Repository
|
||||
if (loginInfo != null && loginInfo.result)
|
||||
{
|
||||
myUser = new User();
|
||||
myUser.Email = loginInfo.Email;
|
||||
myUser.FirstName = loginInfo.FirstName;
|
||||
myUser.LastName = loginInfo.LastName;
|
||||
myUser.Username = loginInfo.StafflinkNo;
|
||||
myUser.Email = loginInfo.email;
|
||||
myUser.FirstName = loginInfo.firstName;
|
||||
myUser.LastName = loginInfo.lastName;
|
||||
myUser.Username = loginInfo.stafflinkNo;
|
||||
//now check the adminuser table
|
||||
var user = _context.AdminUsers.SingleOrDefault(x => x.StafflinkNo == model.Username);
|
||||
if (user != null)
|
||||
@@ -178,10 +178,10 @@ namespace CarParkValidationAPI.Repository
|
||||
if (loginInfo != null && loginInfo.result)
|
||||
{
|
||||
myUser = new User();
|
||||
myUser.Email = loginInfo.Email;
|
||||
myUser.FirstName = loginInfo.FirstName;
|
||||
myUser.LastName = loginInfo.LastName;
|
||||
myUser.Username = loginInfo.StafflinkNo;
|
||||
myUser.Email = loginInfo.email;
|
||||
myUser.FirstName = loginInfo.firstName;
|
||||
myUser.LastName = loginInfo.lastName;
|
||||
myUser.Username = loginInfo.stafflinkNo;
|
||||
statuscode = 1;
|
||||
}
|
||||
|
||||
@@ -222,10 +222,10 @@ namespace CarParkValidationAPI.Repository
|
||||
MyADObject myADObj = staffLink.SearchStaff(username);
|
||||
User user = new()
|
||||
{
|
||||
Username = myADObj.StafflinkNo,
|
||||
Email = myADObj.Email,
|
||||
FirstName = myADObj.FirstName,
|
||||
LastName = myADObj.LastName
|
||||
Username = myADObj.stafflinkNo,
|
||||
Email = myADObj.email,
|
||||
FirstName = myADObj.firstName,
|
||||
LastName = myADObj.lastName
|
||||
};
|
||||
// myADObj.JobTitle;
|
||||
return user;
|
||||
@@ -239,10 +239,10 @@ namespace CarParkValidationAPI.Repository
|
||||
MyADObject myADObj = staffLink.CheckADCredentials(username,password);
|
||||
User user = new()
|
||||
{
|
||||
Username = myADObj.StafflinkNo,
|
||||
Email = myADObj.Email,
|
||||
FirstName = myADObj.FirstName,
|
||||
LastName = myADObj.LastName
|
||||
Username = myADObj.stafflinkNo,
|
||||
Email = myADObj.email,
|
||||
FirstName = myADObj.firstName,
|
||||
LastName = myADObj.lastName
|
||||
};
|
||||
// myADObj.JobTitle;
|
||||
return user;
|
||||
@@ -55,14 +55,14 @@ namespace CarParkValidationAPI.Repository
|
||||
int statuscode = 0;
|
||||
string webAPIUrl = _appSettings.LoginWebAPI;
|
||||
|
||||
var loginInfo = await CommonAD.WebAPIUtil.GetLoginADAsync(webAPIUrl, "CheckADCredentials", model.Username, model.Password);
|
||||
var loginInfo = await CommonAD.WebAPIUtil.PostLoginADAsync(webAPIUrl, "CheckCredentials", model.Username, model.Password);
|
||||
if (loginInfo != null && loginInfo.result)
|
||||
{
|
||||
myUser = new User();
|
||||
myUser.Email = loginInfo.Email;
|
||||
myUser.FirstName = loginInfo.FirstName;
|
||||
myUser.LastName = loginInfo.LastName;
|
||||
myUser.Username = loginInfo.StafflinkNo;
|
||||
myUser.Email = loginInfo.email;
|
||||
myUser.FirstName = loginInfo.firstName;
|
||||
myUser.LastName = loginInfo.lastName;
|
||||
myUser.Username = loginInfo.stafflinkNo;
|
||||
//now check the adminuser table
|
||||
var user = _context.AdminUsers.
|
||||
SingleOrDefault(x => x.StafflinkNo == model.Username
|
||||
@@ -154,10 +154,10 @@ namespace CarParkValidationAPI.Repository
|
||||
if (loginInfo != null && loginInfo.result)
|
||||
{
|
||||
myUser = new User();
|
||||
myUser.Email = loginInfo.Email;
|
||||
myUser.FirstName = loginInfo.FirstName;
|
||||
myUser.LastName = loginInfo.LastName;
|
||||
myUser.Username = loginInfo.StafflinkNo;
|
||||
myUser.Email = loginInfo.email;
|
||||
myUser.FirstName = loginInfo.firstName;
|
||||
myUser.LastName = loginInfo.lastName;
|
||||
myUser.Username = loginInfo.stafflinkNo;
|
||||
statuscode = 1;
|
||||
}
|
||||
|
||||
@@ -198,10 +198,10 @@ namespace CarParkValidationAPI.Repository
|
||||
MyADObject myADObj = staffLink.SearchStaff(username);
|
||||
User user = new()
|
||||
{
|
||||
Username = myADObj.StafflinkNo,
|
||||
Email = myADObj.Email,
|
||||
FirstName = myADObj.FirstName,
|
||||
LastName = myADObj.LastName
|
||||
Username = myADObj.stafflinkNo,
|
||||
Email = myADObj.email,
|
||||
FirstName = myADObj.firstName,
|
||||
LastName = myADObj.lastName
|
||||
};
|
||||
// myADObj.JobTitle;
|
||||
return user;
|
||||
@@ -215,10 +215,10 @@ namespace CarParkValidationAPI.Repository
|
||||
MyADObject myADObj = staffLink.CheckADCredentials(username,password);
|
||||
User user = new()
|
||||
{
|
||||
Username = myADObj.StafflinkNo,
|
||||
Email = myADObj.Email,
|
||||
FirstName = myADObj.FirstName,
|
||||
LastName = myADObj.LastName
|
||||
Username = myADObj.stafflinkNo,
|
||||
Email = myADObj.email,
|
||||
FirstName = myADObj.firstName,
|
||||
LastName = myADObj.lastName
|
||||
};
|
||||
// myADObj.JobTitle;
|
||||
return user;
|
||||
@@ -66,6 +66,7 @@ namespace CarParkValidationAPI
|
||||
};
|
||||
});
|
||||
|
||||
services.AddAutoMapper(typeof(Startup));
|
||||
//**
|
||||
//publish need to take comment out
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
"AppSettings": {
|
||||
"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;",
|
||||
"LDAPPath": "LDAP://ldap.nswhealth.net:389/OU=Accounts,DC=nswhealth,DC=net",
|
||||
"LDAPUser": "SRV-NBMS-BIDSPMS",
|
||||
"LDAPPassword": "42Ytp2AE3nN16eBoyia86UZH6",
|
||||
"LDAPPath": "",
|
||||
"LDAPUser": "S",
|
||||
"LDAPPassword": "",
|
||||
"ADTimeOut": "30",
|
||||
"LoginWebAPI": "http://NEPHMDB-SQL007/CommonWebApiAD/api/AD"
|
||||
},
|
||||
@@ -2,9 +2,9 @@
|
||||
"AppSettings": {
|
||||
"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;",
|
||||
"LDAPPath": "LDAP://ldap.nswhealth.net:389/OU=Accounts,DC=nswhealth,DC=net",
|
||||
"LDAPUser": "SRV-NBMS-BIDSPMS",
|
||||
"LDAPPassword": "42Ytp2AE3nN16eBoyia86UZH6",
|
||||
"LDAPPath": "",
|
||||
"LDAPUser": "S",
|
||||
"LDAPPassword": "",
|
||||
"ADTimeOut": "30",
|
||||
"LoginWebAPI": "http://NEPHMDB-SQL007/CommonWebApiAD/api/AD"
|
||||
|
||||
Reference in New Issue
Block a user