using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using MMDAL.DTO.ForeCastSet; using MMDAL.Query.ForeCastSet; using Newtonsoft.Json; using static GB5Shared.GB5Constant.Constant; namespace MMDAL.CustomCode.ForeCastSet { public class ForeCastSetDAL : IForeCastSetDAL { private readonly IQueryExecutor _QueryExecutor; public ForeCastSetDAL(IQueryExecutor queryExecutor) { _QueryExecutor = queryExecutor; } public async Task GetSelectListForeCastSet(int FirstNumber, int MaxResult, CriteriaDTO CriteriaDTO, LoginDTO LoginDTO) { try { string SQL = string.Empty; switch (LoginDTO.DatabaseType) { case DBType.SQL: SQL = ForeCastSetQB.GET_SELECTLIST_FORECASTSET_SQL; break; case DBType.PostGre: SQL = ForeCastSetQB.GET_SELECTLIST_FORECASTSET_PG; break; case DBType.Oracle: SQL = ForeCastSetQB.GET_SELECTLIST_FORECASTSET_ORACLE; break; case DBType.MySQL: SQL = ForeCastSetQB.GET_SELECTLIST_FORECASTSET_MYSQL; break; default: throw new Exception("Unsupported database type"); } var Parameters = new { firstnumber = FirstNumber, maxresult = MaxResult }; var Result = await _QueryExecutor.QueryAsync(LoginDTO, SQL, Parameters); string Json = JsonConvert.SerializeObject(Result); return Json; } catch (Exception) { throw; } } } }