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