Beispiel #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;
 }
Beispiel #3
0
 public GetAccountDetailsResponse(
     AccountId accountId,
     Money currentBalance,
     List <TransactionModel> transactions)
 {
     this.AccountId      = accountId.ToGuid();
     this.CurrentBalance = currentBalance.ToDecimal();
     this.Transactions   = transactions;
 }
Beispiel #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);
     }
 }
Beispiel #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));
     }
 }
Beispiel #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;
         }
     }
 }
Beispiel #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;
             }
         }
     }
 }
Beispiel #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);
         }
     }
 }
Beispiel #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()));
 }