コード例 #1
0
        public AccountModule(IAccountService accountService, IHttpContextAccessor httpContextAccessor)
        {
            this.context = httpContextAccessor.Current;

            Post["/Account/Create"] = x =>
                                          {
                                              var command = new AddUserAccountCommand(Request.Form.EmailAddress,
                                                                                  Request.Form.Password,
                                                                                  uint.Parse(Request.Form.RateOutOf));
                                              var account = accountService.CreateAccount(command);

                                              var accountValidationUrl = context.Request.BaseUrl() + "/Account/Validate/" + account.Key;

                                              return Response.AsJson(new
                                                                         {
                                                                             AccountKey = account.Key,
                                                                             AccountValidationUrl = accountValidationUrl
                                                                         });
                                          };

            Post["/Account/Validate"] = x =>
                                                           {
                                                               var command = new ValidateAccountCommand(Request.Form.ValidationKey);
                                                               return Response.AsJson((int)accountService.ValidateAccount(command));
                                                           };
        }
コード例 #2
0
 public dynamic ValidateAccount(ValidateAccountCommand command)
 {
     var db = Database.Open();
     var userAccount = db.UserAccounts.FindAllByKey(command.ValidationKey).SingleOrDefault();
     if (userAccount == null) return 0;
     userAccount.Enabled = true;
     return db.UserAccounts.Update(userAccount); ;
 }