public async Task <IActionResult> GetAll() { var _request = new ContactGetAllRequest(); var _result = await _mediator.Send(_request); return(Ok(_result)); }
public async Task <IEnumerable <ContactResponse> > Handle(ContactGetAllRequest request, CancellationToken cancellationToken) { var _result = await _contactService.GetAllAsync(); var _mappedResult = _mapper.Map <IEnumerable <ContactResponse> >(_result); return(_mappedResult); }
public async Task <ContactGetAllResponse> GetAllAsync(ContactGetAllRequest req) { var result = new ContactGetAllResponse(); result = await _repos.GetAllAsync(req); if (result != null && result.Result.Any()) { result.Result.ToList().ForEach(x => { x.DisplayName = x.Name; if (!string.IsNullOrWhiteSpace(x.ContactName)) { x.DisplayName = string.Format("{0} ({1})", x.Name, x.ContactName); } else if (!string.IsNullOrWhiteSpace(x.Zip)) { x.DisplayName = string.Format("{0} (Zip: {1})", x.Name, x.Zip); } }); } return(result); }
public async Task <ContactGetAllResponse> GetAllAsync(ContactGetAllRequest req) { var resp = new ContactGetAllResponse(); 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)) { string storeproc = string.Format("[dbo].[usp{0}GetListNew]", req.ContactType); await conn.OpenAsync(); var dynparam = new { Query = tempQuery }; var rawResult = await conn.QueryAsync <ContactDTO>(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); }
public async Task <IActionResult> ContactGetAllAsync(ContactGetAllRequest req) { var result = await _contactManager.GetAllAsync(req); return(Ok(result)); }