Example #1
0
        public IActionResult Register([FromBody] Users model)
        {
            Users result = new Users();

            try
            {
                ServiceAction action = new ServiceAction(Configuration);
                action.CheckUser(out result, model.Username);
                if (result != null)
                {
                    return(BadRequest());
                }
                model.Password = Crypto.HashPassword(model.Password);
                action.Register(model);
                return(Ok(new { result = "ok", message = "register successfully" }));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to execute POST");
                return(StatusCode(500, new { result = "", message = ex.Message }));
            }
        }