示例#1
0
        public IActionResult Post([FromBody] Object obj)
        {
            var resource = shaper.FormatObject(obj);

            if (checker.ValidateModel(resource))
            {
                repo.Create(resource);
                return(Created(resource));
            }

            return(BadRequest());
        }
        public IActionResult Register([FromBody] Object obj)
        {
            // Retrieve actual class of the model
            var resource = shaper.FormatObject(obj);

            // Encrypt the user's credentials for security
            resource = crypto.EncryptUserPassword(resource);

            if (checker.ValidateModel(resource))
            {
                repo.Create(resource);
                return(Ok("Registration successful."));
            }

            return(BadRequest("Registration failed."));
        }