using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using MMDAL.DTO.PostingPosition; using MMDAL.Query.PostingPosition; using Newtonsoft.Json; using System; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace MMDAL.CustomCode.PostingPosition { public class PostingPositionDAL : IPostingPositionDAL { private readonly IQueryExecutor _QueryExecutor; public PostingPositionDAL(IQueryExecutor QueryExecutor) { _QueryExecutor = QueryExecutor; } public async Task GetSelectListPostingPosition(int FirstNumber, int MaxResult, CriteriaDTO CriteriaDTO, LoginDTO LoginDTO) { try { string SQL = string.Empty; switch (LoginDTO.DatabaseType) { case DBType.SQL: SQL = PostingPositionQB.GET_SELECTLIST_POSTINGPOSITION_SQL; break; case DBType.PostGre: SQL = PostingPositionQB.GET_SELECTLIST_POSTINGPOSITION_PG; break; case DBType.Oracle: SQL = PostingPositionQB.GET_SELECTLIST_POSTINGPOSITION_ORACLE; break; case DBType.MySQL: SQL = PostingPositionQB.GET_SELECTLIST_POSTINGPOSITION_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; } } } }