コード例 #1
0
        public IActionResult CreateSignature([FromBody] Signature signature)
        {
            try
            {
                if (signature.IsObjectNull())
                {
                    _logger.LogError("Signature object sent from client is null.");
                    return(BadRequest("Signature object is null"));
                }

                if (!ModelState.IsValid)
                {
                    _logger.LogError("Invalid signature object sent from client.");
                    return(BadRequest("Invalid model object"));
                }

                _signatureService.Create(signature);
                return(CreatedAtRoute("SignatureById", new { id = signature.Id }, signature));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside CreateSignature action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }