-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aaron
committed
May 13, 2020
1 parent
5eadccf
commit 268130f
Showing
2 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using DVSA.MOT.SDK.Models; | ||
|
||
namespace DVSA.MOT.SDK.Interfaces | ||
{ | ||
public interface IAllVehiclesService | ||
{ | ||
MotTestResponses GetAllMotTests(int page); | ||
MotTestResponses GetAllMotTestsByDate(DateTime date, int page); | ||
Task<ApiResponse> GetAllMotTests(int page); | ||
Task<ApiResponse> GetAllMotTestsByDate(DateTime date, int page); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using DVSA.MOT.SDK.Interfaces; | ||
using DVSA.MOT.SDK.Models; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace DVSA.MOT.SDK.Services | ||
{ | ||
public class AllVehiclesService : IAllVehiclesService | ||
{ | ||
public MotTestResponses GetAllMotTests(int page) | ||
private readonly ILogger<SingleVehicleService> _logger; | ||
private readonly IProcessApiResponse _processApiResponse; | ||
|
||
public AllVehiclesService(ILogger<SingleVehicleService> logger, IProcessApiResponse processApiResponse) | ||
{ | ||
_logger = logger; | ||
_processApiResponse = processApiResponse; | ||
} | ||
|
||
public async Task<ApiResponse> GetAllMotTests(int page) | ||
{ | ||
throw new NotImplementedException(); | ||
try | ||
{ | ||
var parameters = new List<KeyValuePair<string, string>> | ||
{ | ||
new KeyValuePair<string, string>(Constants.Parameters.Page, page.ToString()) | ||
}; | ||
return await _processApiResponse.GetData(parameters); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.Log(LogLevel.Error, ex, ex.Message); | ||
return null; | ||
} | ||
} | ||
|
||
public MotTestResponses GetAllMotTestsByDate(DateTime date, int page) | ||
public async Task<ApiResponse> GetAllMotTestsByDate(DateTime date, int page) | ||
{ | ||
throw new NotImplementedException(); | ||
try | ||
{ | ||
var parameters = new List<KeyValuePair<string, string>> | ||
{ | ||
new KeyValuePair<string, string>(Constants.Parameters.Date, date.ToString("yyyyMMdd")), | ||
new KeyValuePair<string, string>(Constants.Parameters.Page, page.ToString()) | ||
}; | ||
return await _processApiResponse.GetData(parameters); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.Log(LogLevel.Error, ex, ex.Message); | ||
return null; | ||
} | ||
} | ||
} | ||
} |