コード例 #1
0
        public HttpResponseMessage Register([FromBody]RegistrationAccountModel model)
        {
            return SafeAction(() =>
            {
                if (!model.Password.Equals(model.Confirm, StringComparison.InvariantCulture))
                {
                    throw new InvalidPasswordsException();
                }
                if (!CaptchaProvider.Validate(model.Captcha.Id, model.Captcha.Text))
                {
                    throw new InvalidCaptchaCodeException();
                }

                IDelightServices service = new DelightServices();

                if (String.IsNullOrEmpty(model.Type))
                {
                    service.RegisterUser(model.Username, model.Password, model.Email);
                }
                else
                {
                    service.RegisterOwner(model.Username, model.Password, model.Email);
                }
                return Request.CreateResponse(HttpStatusCode.OK, true);
            }, model);
        }