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

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

            try
            {
                if (ModelState.IsValid)
                {
                    await _evalRepository.CreateSubProductAsync(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());
        }