public IEnumerable <RecordModel> GetClimateRecordPage(int pageIndex, int pageSize) { string query = RecordPageQuery + PagingClause; using var dal = new DalSession(Configuration); return(dal.Connection.Query <RecordModel>(query, new { Offset = (pageIndex - 1) * pageSize, PageSize = pageSize }).ToList()); }
public IEnumerable <RecordModel> GetFilteredRecords(string searchStation, string month, string province, int pageIndex, int pageSize) { string query = RecordPageQuery + "WHERE "; bool monthAdded = false; bool provinceAdded = false; query.Replace(MonthFilteringClause, ""); query.Replace(ProvinceFilteringClause, ""); query.Replace(StationFilteringClause, ""); if (!string.IsNullOrEmpty(province)) { query = query + ProvinceFilteringClause; provinceAdded = true; } if (!string.IsNullOrEmpty(month)) { if (provinceAdded) { query = query + "AND "; } query = query + MonthFilteringClause; monthAdded = true; } if (!string.IsNullOrEmpty(searchStation)) { if (monthAdded) { query = query + "AND "; } query = query + StationFilteringClause; } //query = query + PagingClause; DateTime?selectMonth = DateTime.ParseExact(month, "yyyy-MM-dd", new CultureInfo("en-US")); using var dal = new DalSession(Configuration); return(dal.Connection.Query <RecordModel>(query, new { Offset = (pageIndex - 1) * pageSize, PageSize = pageSize, Month = selectMonth, Province = province, Filter = searchStation }).ToList()); }
public IEnumerable <StationDetailModel> GetStationDetails(int pageIndex, int pageSize, int id) { using var dal = new DalSession(Configuration); return(dal.Connection.Query <StationDetailModel>(StationDetailQuery + WhereClause, new { Offset = (pageIndex - 1) * pageSize, PageSize = pageSize, StationID = id }).ToList()); }
public IEnumerable <StationListModel> GetStationList(int pageIndex, int pageSize) { using var dal = new DalSession(Configuration); return(dal.Connection.Query <StationListModel>(StationListQuery, new { Offset = (pageIndex - 1) * pageSize, PageSize = pageSize }).ToList()); }
public int GetClimateRecordCount() { using var dal = new DalSession(Configuration); return(dal.Connection.ExecuteScalar <int>(RecordCountQuery)); }