コード例 #1
0
ファイル: PostsController.cs プロジェクト: t4rn/Gugleus
        private async Task <IActionResult> GetRequestResponseAsync <T>(long id, RequestType.RequestTypeCode requestType) where T : class
        {
            IActionResult result;

            try
            {
                ObjResult <RequestResponseDto <T> > requestStatusResult =
                    await _requestService.GetRequestResponseAsync <T>(id, requestType);

                if (requestStatusResult.IsOk)
                {
                    _logger.LogDebug("{0} Ok for Id: '{1}' type: '{2}' -> {3}",
                                     LogDescription(), id, requestType, requestStatusResult.Object.Status);
                    result = Ok(requestStatusResult.Object);
                }
                else
                {
                    _logger.LogError($"{LogDescription()} Request with Id: '{id}' and type '{requestType}' not found");
                    result = BadRequest($"Request with Id: '{id}' not found...");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("[{0}] Ex for Id: '{1}' type: '{2}': {3}", nameof(GetRequestResponseAsync), id, requestType, ex);
                result = InternalServerError(ex.Message);
            }
            return(result);
        }
コード例 #2
0
        public async Task <ObjResult <RequestResponseDto <T> > > GetRequestResponseAsync <T>(long id, RequestType.RequestTypeCode requestType) where T : class
        {
            ObjResult <RequestResponseDto <T> > res = new ObjResult <RequestResponseDto <T> >();

            Request request = await _requestRepository.GetRequestWithQueueAsync(id, requestType.ToString());

            if (request != null)
            {
                res.IsOk   = true;
                res.Object = PrepareRequestResponse <T>(request);
            }
            else
            {
                res.Message = $"Request with Id: '{id}' not found...";
            }

            return(res);
        }