put in the file auto mapping and change file.

change spelling too.
This commit is contained in:
Kham
2021-12-10 11:30:30 +11:00
parent 87c89897c2
commit 52d2af93e2
7 changed files with 472 additions and 11 deletions
@@ -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;
@@ -42,7 +42,7 @@ namespace CarParkValidationAPI.Repository
style.SetFont("Arial Black", 16);
sl.SetCellStyle(1, 5, style);
sl.SetRowHeight(1, 1, 25);
sl.SetCellValue(row++, 5, "The ConssionValidation Report");
sl.SetCellValue(row++, 5, "The Concession Validation Report");
sl.SetCellValue(row, 3, "Date Range: " + fromDate.ToString(dateFormat) + " - " + toDate.ToString(dateFormat) );
sl.SetCellValue(1, 6, " " + DateTime.Now.ToString("ddd dd/MM/yyyy HH:mm"));