public async Task <AgencyGetAllResponse> GetAllAsync(AgencyGetAllRequest req)
        {
            var resp      = new AgencyGetAllResponse();
            var tempQuery = string.Empty;
            var startRow  = 0;
            var endRow    = 0;

            if (req.Predicate != null)
            {
                tempQuery = req.Predicate.ConvertToString();
                startRow  = req.Predicate.StartRow;
                endRow    = req.Predicate.EndRow;
            }
            using (var conn = new SqlConnection(_connectionSettings.DefaultConnection))
            {
                const string storeproc = @"[dbo].[uspAgenciesGetList_New]";
                await conn.OpenAsync();

                var dynparam = new
                {
                    Query = tempQuery
                };
                var rawResult = await conn.QueryAsync <AgencyDTO>(storeproc, dynparam, null, null, CommandType.StoredProcedure);

                resp.Total = rawResult != null && rawResult.Any() ? rawResult.Count() : 0;
                if (startRow >= 0 && endRow >= 0)
                {
                    resp.Result = rawResult.ToList().Skip(startRow).Take(endRow - startRow).ToList();
                }
                else
                {
                    resp.Result = rawResult.ToList();
                }
            }
            return(resp);
        }
Esempio n. 2
0
        public async Task <IActionResult> AgencyGetAllAsync(AgencyGetAllRequest req)
        {
            var result = await _AgencyManager.GetAllAsync(req);

            return(Ok(result));
        }
Esempio n. 3
0
        public async Task <AgencyGetAllResponse> GetAllAsync(AgencyGetAllRequest req)
        {
            var result = await _repos.GetAllAsync(req);

            return(result);
        }