示例#1
0
 public int IncrementFailedLoginAttemptCount(AccountId accountId)
 {
     using (var db = new THCard()) {
         using (var transaction = new TransactionScope(TransactionScopeOption.Required,
                                                       new TransactionOptions {
             IsolationLevel = IsolationLevel.RepeatableRead
         })) {
             FailedLoginAttempt dbFailedLoginAttempt = FindFailedLoginAttempt(db, accountId.ToGuid());
             if (dbFailedLoginAttempt == null)
             {
                 db.FailedLoginAttempts.Add(new FailedLoginAttempt {
                     AccountId = accountId.ToGuid(), FailedLoginAttemptCount = 0
                 });
                 db.SaveChanges();
                 transaction.Complete();
                 return(1);
             }
             else
             {
                 ++dbFailedLoginAttempt.FailedLoginAttemptCount;
                 db.SaveChanges();
                 transaction.Complete();
                 return(dbFailedLoginAttempt.FailedLoginAttemptCount);
             }
         }
     }
 }
 public AccountDetailsModel(
     AccountId accountId,
     Money currentBalance,
     List <TransactionModel> transactions)
 {
     AccountId      = accountId.ToGuid();
     CurrentBalance = currentBalance.ToDecimal();
     Transactions   = transactions;
 }
示例#3
0
 public GetAccountDetailsResponse(
     AccountId accountId,
     Money currentBalance,
     List <TransactionModel> transactions)
 {
     this.AccountId      = accountId.ToGuid();
     this.CurrentBalance = currentBalance.ToDecimal();
     this.Transactions   = transactions;
 }
示例#4
0
 public AccountManagement.User GetUser(AccountId accountId)
 {
     Contract.Requires(accountId != null && !accountId.IsNew);
     using (var db = new THCard()) {
         Account dbAccount = db.Accounts.Find(accountId.ToGuid());
         if (dbAccount == null) {
             throw new InvalidOperationException("Account not found.");
         }
         return MapToUser(dbAccount.User);
     }
 }
示例#5
0
 public AccountManagement.User GetUser(AccountId accountId)
 {
     Contract.Requires(accountId != null && !accountId.IsNew);
     using (var db = new THCard()) {
         Account dbAccount = db.Accounts.Find(accountId.ToGuid());
         if (dbAccount == null)
         {
             throw new InvalidOperationException("Account not found.");
         }
         return(MapToUser(dbAccount.User));
     }
 }
示例#6
0
 public AccountManagement.Account GetAccount(AccountId accountId)
 {
     using (var db = new THCard()) {
         Account dbAccount = FindAccountById(db, accountId.ToGuid());
         if (dbAccount != null) {
             return MapAccount(dbAccount);
         }
         else {
             return null;
         }
     }
 }
示例#7
0
 public int IncrementFailedLoginAttemptCount(AccountId accountId)
 {
     using (var db = new THCard()) {
         using (var transaction = new TransactionScope(TransactionScopeOption.Required,
                                                       new TransactionOptions {
                                                           IsolationLevel = IsolationLevel.RepeatableRead
                                                       })) {
             FailedLoginAttempt dbFailedLoginAttempt = FindFailedLoginAttempt(db, accountId.ToGuid());
             if (dbFailedLoginAttempt == null) {
                 db.FailedLoginAttempts.Add(new FailedLoginAttempt {AccountId = accountId.ToGuid(), FailedLoginAttemptCount = 0});
                 db.SaveChanges();
                 transaction.Complete();
                 return 1;
             }
             else {
                 ++dbFailedLoginAttempt.FailedLoginAttemptCount;
                 db.SaveChanges();
                 transaction.Complete();
                 return dbFailedLoginAttempt.FailedLoginAttemptCount;
             }
         }
     }
 }
示例#8
0
 public AccountManagement.Account GetAccount(AccountId accountId)
 {
     using (var db = new THCard()) {
         Account dbAccount = FindAccountById(db, accountId.ToGuid());
         if (dbAccount != null)
         {
             return(MapAccount(dbAccount));
         }
         else
         {
             return(null);
         }
     }
 }
示例#9
0
 /// <summary>
 /// Retrieve an account list item from the repository.
 /// </summary>
 /// <param name="id">Account Id</param>
 /// <returns>Reference to the account list item in the repository, if found. <c>null</c> otherwise.</returns>
 public AccountListItem Find(AccountId id)
 {
     return(this.readStore.Retrieve <AccountListItem>(id.ToGuid()));
 }