コード例 #1
0
ファイル: NotesController.cs プロジェクト: rudym/sample
        public async Task <IActionResult> Get([FromRoute] string entityId, [FromRoute] string noteId)
        {
            _logger.LogDebug($"GET Note by Note Code {entityId} {noteId}.");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = await _repositoryService.GetRecordAsync(entityId + "-" + noteId);

                if (result != null)
                {
                    return(Ok(new Response <Note> {
                        Results = new[] { result }
                    }));
                }

                return(Ok(ResponseHelp.ReturnEmptyObjectResult <Note>()));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to fetch Note data result.");
                return(StatusCode(500, "An unexpected error has occurred."));
            }
        }
コード例 #2
0
ファイル: CustomersController.cs プロジェクト: rudym/sample
        public async Task <IActionResult> Get([FromRoute] string id)
        {
            _logger.LogDebug($"GET Customer by Customer Code {id}.");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = await _repositoryService.GetRecordAsync(id);

                if (result != null)
                {
                    return(Ok(new Response <Customer> {
                        Results = new[] { result }
                    }));
                }

                return(Ok(ResponseHelp.ReturnEmptyObjectResult <Customer>()));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to fetch Customer data result.");
                return(StatusCode(500, "An unexpected error has occurred."));
            }
        }