modified default for user
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<UserSecretsId>punt</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -71,6 +71,19 @@ namespace CarParkValidationAPI.Controllers
|
||||
var retval = await _concessionValidation.LoadConcessionValidationByIdAsync(id);
|
||||
return Ok(retval);
|
||||
}
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> GetConcessionCard(CardNoCriteria criteria)
|
||||
{
|
||||
/*
|
||||
// only admins can access other user records
|
||||
var currentUser = (User)HttpContext.Items["User"];
|
||||
if (id != currentUser.Id && currentUser.Role != Role.Admin)
|
||||
return Unauthorized(new { message = "Unauthorized" });
|
||||
*/
|
||||
var retval = await _concessionValidation.LoadConcessionValidationByCardNumberAsync(criteria.CardNo);
|
||||
return Ok(retval);
|
||||
}
|
||||
|
||||
[HttpDelete("{id:int}")]
|
||||
public async Task<IActionResult> DeleteConcessionValidation(int id)
|
||||
{
|
||||
|
||||
@@ -32,14 +32,14 @@ namespace CarParkValidationAPI.Controllers
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> LoginAD(AuthenticateRequest model)
|
||||
public async Task<IActionResult> LoginAD([FromBody] AuthenticateRequest model)
|
||||
{
|
||||
var response = await _userService.LoginAD(model);
|
||||
return Ok(response);
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> LoginApiAD(AuthenticateRequest model)
|
||||
public async Task<IActionResult> LoginApiAD([FromBody] AuthenticateRequest model)
|
||||
{
|
||||
var response = await _userService.LoginApiAD(model);
|
||||
return Ok(response);
|
||||
|
||||
@@ -5,6 +5,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CarParkValidationAPI.Entities
|
||||
{
|
||||
public class CardNoCriteria
|
||||
{
|
||||
public string CardNo { get; set; }
|
||||
}
|
||||
public class ConcessionValidationExtDto: ConcessionValidationDto
|
||||
{
|
||||
public string ConcessionType { get; set; }
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CarParkValidationAPI.Repository;
|
||||
|
||||
|
||||
namespace CarParkValidationAPI.Interface
|
||||
@@ -15,6 +16,7 @@ namespace CarParkValidationAPI.Interface
|
||||
Task<ResultModel<int>> CheckConcessionValidationStaffLinkNoAsync(string staffLinkNo, string concessionCard, DateTime currentDate, int id);
|
||||
Task<ResultModel<int>> SaveConcessionValidationAsync(ConcessionValidationDto item);
|
||||
Task<ResultModel<ConcessionValidationDto>> LoadConcessionValidationByIdAsync(int id);
|
||||
Task<ResultModel<ConcessionValidationDto>> LoadConcessionValidationByCardNumberAsync(string cardNo);
|
||||
Task<ResultModel<bool>> DeleteConcessionValidationAsync(int id);
|
||||
|
||||
void SetCurrentUser(string username);
|
||||
|
||||
@@ -12,6 +12,7 @@ using CarParkValidationAPI.Datas;
|
||||
using CarParkValidationAPI.Interface;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Security.Cryptography.Xml;
|
||||
|
||||
namespace CarParkValidationAPI.Repository
|
||||
{
|
||||
@@ -238,18 +239,54 @@ namespace CarParkValidationAPI.Repository
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResultModel<ConcessionValidationDto>> LoadConcessionValidationByIdAsync(int id)
|
||||
public async Task<ResultModel<ConcessionValidationDto>> LoadConcessionValidationByIdAsync(int id)
|
||||
{
|
||||
ConcessionValidationDto result = null;
|
||||
int statuscode = 0;
|
||||
string error = "";
|
||||
try
|
||||
{
|
||||
if (id > 0)
|
||||
{
|
||||
ConcessionValidation model = await _context.ConcessionValidations.FindAsync(id);
|
||||
result = FillConcessionValidationDto(model);
|
||||
statuscode = 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
statuscode = 0;
|
||||
error = ex.ToString();
|
||||
throw;
|
||||
}
|
||||
|
||||
return new ResultModel<ConcessionValidationDto>()
|
||||
{
|
||||
Data = result,
|
||||
StatusCode = statuscode,
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
public async Task<ResultModel<ConcessionValidationDto>> LoadConcessionValidationByCardNumberAsync(string cardNo)
|
||||
{
|
||||
ConcessionValidationDto result = null;
|
||||
int statuscode = 0;
|
||||
string error = "";
|
||||
try
|
||||
{
|
||||
if (id > 0)
|
||||
if (!string.IsNullOrEmpty(cardNo))
|
||||
{
|
||||
ConcessionValidation model = await _context.ConcessionValidations.FindAsync(id);
|
||||
result = FillConcessionValidationDto(model);
|
||||
statuscode = 1;
|
||||
|
||||
var list = await _context.ConcessionValidations.Where(x => x.ConcessionCard == cardNo).ToListAsync();
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
|
||||
result = FillConcessionValidationDto(list[0]);
|
||||
statuscode = 1;
|
||||
}
|
||||
else
|
||||
statuscode = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user