Beispiel #1
0
        public async Task <ActionResult <SuccessResponse> > CreateProduct([FromBody] Product Product)
        {
            _logger.LogInformation("Calling CreateProduct on the repository");

            var error = new ErrorResponse {
                RequestId = HttpContext?.TraceIdentifier ?? Guid.NewGuid().ToString()
            };

            try
            {
                if (ModelState.IsValid)
                {
                    await _evalRepository.CreateProductAsync(Product);

                    return(Ok());
                }
            }
            catch (Exception e)
            {
                error.Errors.Add(ErrorModel.FromApiErrorCode(ApiErrorCode.FailToGetData));
                _logger.LogError($"Fail to retrieve prescribing information {e.Message}", e);
                return(StatusCode((int)HttpStatusCode.InternalServerError, error));
            }

            return(BadRequest());
        }