commit change all folder
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
//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.ConcessionTypeID,
|
||||
Description = x.ConcessionDesc,
|
||||
|
||||
}).ToListAsync();
|
||||
statuscode = 1;
|
||||
result.Sort((x,y) => x.Description.CompareTo(y.Description));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
statuscode = 0;
|
||||
error = ex.ToString();
|
||||
throw;
|
||||
}
|
||||
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.ValidationPointID,
|
||||
Description = x.Description
|
||||
}).ToListAsync();
|
||||
result.Sort((x, y) => x.Description.CompareTo(y.Description));
|
||||
statuscode = 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
statuscode = 0;
|
||||
error = ex.ToString();
|
||||
throw;
|
||||
}
|
||||
return new ResultModel<List<LookupCodeDto>>()
|
||||
{
|
||||
Data = result,
|
||||
StatusCode = statuscode,
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user