using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using LogisticsDAL.DTO.ManiFest; using LogisticsDAL.Query.Manifest; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace LogisticsDAL.CustomCode.Manifest { public class ManifestDAL : IManifestDAL { private readonly IQueryExecutor _QueryExecutor; public ManifestDAL(IQueryExecutor queryExecutor) { _QueryExecutor = queryExecutor; } public async Task GetSelectListManifest(int FirstNumber, int MaxResult, CriteriaDTO CriteriaDTO, LoginDTO LoginDTO) { try { string SQL = string.Empty; switch (LoginDTO.DatabaseType) { case DBType.SQL: SQL = ManifestQB.GET_MANIFEST_SELECTLIST_SQL; break; case DBType.PostGre: SQL = ManifestQB.GET_MANIFEST_SELECTLIST_PG; break; case DBType.Oracle: SQL = ManifestQB.GET_MANIFEST_SELECTLIST_ORACLE; break; case DBType.MySQL: SQL = ManifestQB.GET_MANIFEST_SELECTLIST_MYSQL; break; default: throw new Exception("Unsupported database type"); } var Parameters = new { firstnumber = FirstNumber, maxresult = MaxResult }; var Result = await _QueryExecutor.QueryAsync(LoginDTO, SQL, Parameters); return JsonConvert.SerializeObject(Result); } catch (Exception) { throw; } } } }