public async Task <IActionResult> Get()
        {
            var result = await _contactManager.GetAllAsync();

            if (result.IsSuccess)
            {
                var resultDto = _mapper.Map <List <ContactListDto> >(result.Data);
                return(Ok(resultDto));
            }
            return(BadRequest(new { Message = result.Message }));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetAllAsync()
        {
            var querySet = _jsonApiBuilder.BuildQuerySet(HttpContext.Request.Query);

            var pagedContacts = await _contactManager.GetAllAsync(querySet);

            var contactDtos = _mapper.Map <IEnumerable <ContactDto> >(pagedContacts.Items, opt => opt.Items["include"] = querySet.Include);
            var included    = _includedCollector.CollectIncluded(pagedContacts.Items, querySet.Include);
            var links       = _jsonApiBuilder.BuildCollectionLinks(HttpContext.Request.Path, querySet, pagedContacts);
            var meta        = _jsonApiBuilder.BuildCollectionMetadata(pagedContacts);

            return(Ok(new ResourceResponse()
            {
                Meta = meta, Links = links, Data = contactDtos, Included = included
            }));
        }
        public async Task <IActionResult> ContactGetAllAsync(ContactGetAllRequest req)
        {
            var result = await _contactManager.GetAllAsync(req);

            return(Ok(result));
        }
 public IActionResult GetAll()
 {
     return(new WebApiGet <ContactCollectionResult, ContactCollection, Contact>(this, () => _manager.GetAllAsync(),
                                                                                operationType: OperationType.Read, statusCode: HttpStatusCode.OK, alternateStatusCode: HttpStatusCode.NoContent));
 }