public async Task <DlmtCaseGetAllResponse> GetAllAsync(DlmtCaseGetAllRequest req) { var tempColumnSchemas = new Dictionary <string, string> { { "id", "C.ID" }, { "caseNumber", "C.CaseNumber" }, { "caseType", "CT.CaseType" }, { "planningOffice", "PO.[Name]" }, { "area", "A.[Name]" }, { "agency", "AG.Name" } }; if (req.Predicate != null && req.Predicate.Filter != null && req.Predicate.Filter.FilterQueries.Any()) { foreach (var d in tempColumnSchemas) { var tempFilter = req.Predicate.Filter.FilterQueries.FirstOrDefault(x => x.ColumnName.Equals(d.Key, StringComparison.CurrentCultureIgnoreCase)); if (tempFilter != null) { tempFilter.ColumnName = d.Value; } } } if (req.Predicate != null && req.Predicate.Sort != null && req.Predicate.Sort.SortConditions.Any()) { foreach (var d in tempColumnSchemas) { var tempSort = req.Predicate.Sort.SortConditions.FirstOrDefault(x => x.ColumnName.Equals(d.Key, StringComparison.CurrentCultureIgnoreCase)); if (tempSort != null) { tempSort.ColumnName = d.Value; } } } var result = await _repos.GetAllAsync(req); return(result); }
public async Task <DlmtCaseGetAllResponse> GetAllAsync(DlmtCaseGetAllRequest req) { var resp = new DlmtCaseGetAllResponse(); var tempQuery = string.Empty; var tempQueryWithNoSort = string.Empty; var startRow = 0; var endRow = 0; if (req.Predicate != null) { tempQuery = req.Predicate.ConvertToString(); tempQueryWithNoSort = req.Predicate.ConvertToStringWithNoOrder(); startRow = req.Predicate.StartRow; endRow = req.Predicate.EndRow; } using (var conn = new SqlConnection(_connectionSettings.DefaultConnection)) { const string storeproc = @"[dbo].[uspFindCase_New]"; await conn.OpenAsync(); var dynparam = new { Query = tempQuery, StartRow = startRow, EndRow = endRow }; var rawResult = await conn.QueryAsync <CaseSearchDTO>(storeproc, dynparam, null, null, CommandType.StoredProcedure); var tempTotal = await conn.QueryAsync <int>("[dbo].[uspFindCaseTotal_New]", new { Query = tempQueryWithNoSort }, null, null, CommandType.StoredProcedure); resp.Total = tempTotal != null?tempTotal.FirstOrDefault() : 0; resp.Result = rawResult.ToList(); } return(resp); }
public async Task <IActionResult> DlmtCaseGetAllAsync(DlmtCaseGetAllRequest req) { var result = await _dlmtCasemanager.GetAllAsync(req); return(Ok(result)); }