Exemplo n.º 1
0
        public virtual async Task <IDataResponse <PersonViewModel> > GetAsync(
            GetRequest request, CancellationToken token = default)
        {
            request.ArgumentNullCheck(nameof(request));
            request.Id.ArgumentOutOfRangeCheck(nameof(request.Id));

            var entity = await store.GetEntityAsync(request.Id, token);

            IDataResponse <PersonViewModel> response;

            if (entity == null)
            {
                response = NotFoundDataResponse <PersonViewModel>(request.Id);
            }
            else
            {
                var viewModel = new PersonViewModel(entity.Id, entity);
                response = new DataResponse <PersonViewModel>(viewModel, request.Id);
            }

            return(response);
        }