95 lines
2.3 KiB
C#
95 lines
2.3 KiB
C#
//using BCryptNet = BCrypt.Net.BCrypt;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Options;
|
|
using CarParkValidationAPI.Authorization;
|
|
using CarParkValidationAPI.Entities;
|
|
using CarParkValidationAPI.Helpers;
|
|
using CarParkValidationAPI.Models.Users;
|
|
using CarParkValidationAPI.Models;
|
|
using CarParkValidationAPI.Datas;
|
|
using CarParkValidationAPI.Interface;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
|
|
namespace CarParkValidationAPI.Repository;
|
|
|
|
|
|
public class LookupCodeRepository: ILookupCode
|
|
{
|
|
private DataContext _context;
|
|
|
|
private readonly AppSettings _appSettings;
|
|
|
|
public LookupCodeRepository(
|
|
DataContext context,
|
|
|
|
IOptions<AppSettings> appSettings)
|
|
{
|
|
_context = context;
|
|
_appSettings = appSettings.Value;
|
|
}
|
|
public async Task<ResultModel<List<LookupCodeDto>>> LoadConcessionTypeAsync(bool onlyActive)
|
|
{
|
|
List<LookupCodeDto> result = null;
|
|
int statuscode = 0;
|
|
string error = "";
|
|
try
|
|
{
|
|
result = await _context.ConcessionTypes.Where(x => x.Active == onlyActive).Select(
|
|
x => new LookupCodeDto()
|
|
{
|
|
Id = x.Id,
|
|
Description = x.ConcessionDesc,
|
|
|
|
}).ToListAsync();
|
|
statuscode = 1;
|
|
result.Sort((x,y) => x.Description.CompareTo(y.Description));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
statuscode = -1;
|
|
error = ex.ToString();
|
|
|
|
}
|
|
return new ResultModel<List<LookupCodeDto>>()
|
|
{
|
|
Data = result,
|
|
StatusCode = statuscode,
|
|
Message = error
|
|
};
|
|
}
|
|
public async Task<ResultModel<List<LookupCodeDto>>> LoadValidationPointAsync(bool onlyActive)
|
|
{
|
|
List<LookupCodeDto> result = null;
|
|
int statuscode = 0;
|
|
string error = "";
|
|
try
|
|
{
|
|
|
|
result = await _context.Validations.Where(x => x.Active == onlyActive).Select(
|
|
x => new LookupCodeDto()
|
|
{
|
|
Id = x.Id,
|
|
Description = x.Description
|
|
}).ToListAsync();
|
|
result.Sort((x, y) => x.Description.CompareTo(y.Description));
|
|
statuscode = 1;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
statuscode = -1;
|
|
error = ex.ToString();
|
|
|
|
}
|
|
return new ResultModel<List<LookupCodeDto>>()
|
|
{
|
|
Data = result,
|
|
StatusCode = statuscode,
|
|
Message = error
|
|
};
|
|
}
|
|
|
|
}
|