public bool isValidUser(string Email, string?Password = null) { try { using (ITransaction transaction = _session.BeginTransaction()) { if (Password == null) { var result = _session.Query <User>() .Where(user_login => user_login.Email == Email) .Count() > 0; return(result); } else { var result = _session.Query <User>() .Where(user_login => user_login.Email == Email && user_login.Password == Password) .Count() > 0; return(result); } } } catch { throw new IsUserValidException(_path, "isValidUser()"); } finally { _nHibernateService.CloseSession(); } }
public async Task NewTransaction(int AccountId, string Type, string Symbol, int StockCount, float CostPerStock, float CostPerTransaction, DateTime TransactionDate) { try { using (ITransaction transaction = _session.BeginTransaction()) { var stock_transaction = new Transaction { AccountId = AccountId, Type = Type, Symbol = Symbol, StockCount = StockCount, CostPerStock = CostPerStock, CostPerTransaction = CostPerTransaction, TransactionDate = TransactionDate }; await _session.SaveAsync(stock_transaction); await transaction.CommitAsync(); } } catch { throw new NewTransactionException(_path, "NewTransaction()"); } finally { _nHibernateService.CloseSession(); } }
public IQueryable <Account> GetAccount(int UserId) { try { using (ITransaction transaction = _session.BeginTransaction()) { var result = _session.Query <Account>() .Where(account => account.UserId == UserId); return(result); } } catch { throw new GetAccountException(_path, "GetAccount()"); } finally { _nHibernateService.CloseSession(); } }
public bool HoldingExists(int AccountId, string Symbol) { try { using (ITransaction transaction = _session.BeginTransaction()) { var result = _session.Query <Holdings>() .Where(holding => holding.AccountId == AccountId && holding.Symbol == Symbol) .Count() > 0; return(result); } } catch { throw new HoldingExistsException(_path, "HoldingExists()"); } finally { _nHibernateService.CloseSession(); } }