Ejemplo n.º 1
0
        public static SecurityUser AuthenticateUser(string username, string password)
        {
            SecurityUser user = null;

            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0] = new SqlParameter("UserName", username);

                //have to do this because ie is an ass about getting this for some reason...
                int            counter = 0;
                int            limit   = 10;
                UserAuthEntity u       = null;
                do
                {
                    u = context.ExecuteSproc <UserAuthEntity>("usp_GetUserCredentals", sparams).FirstOrDefault();
                    counter++;
                } while (u == null || counter > limit);

                if (u != null && Security.PasswordHash.ValidatePassword(password, u.Hash))
                {
                    SqlParameter[] sparams2 = new SqlParameter[1];
                    sparams2[0] = new SqlParameter("UserName", username);

                    return(context.ExecuteSproc <SecurityUser>("usp_GetUser", sparams2).FirstOrDefault());
                }
            }

            return(user);
        }
Ejemplo n.º 2
0
 public IEnumerable <CurrencyEntity> GetActiveCurrenciesWithCurrentRates()
 {
     using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
     {
         return(context.ExecuteSproc <CurrencyEntity>("usp_GetCurrenciesWithCurrentRates"));
     }
 }
Ejemplo n.º 3
0
 internal override void RefreshData()
 {
     using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
     {
         this.EntityData = context.ExecuteSproc <CurrencyEntity>("usp_GetCurrencies");
     }
 }
Ejemplo n.º 4
0
 private IEnumerable <CurrencySource> GetData(string sourceFrom)
 {
     //get full list from db
     using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
     {
         if (sourceFrom != "")
         {
             SqlParameter[] sparams = new SqlParameter[1];
             sparams[0]           = new SqlParameter("SourceFrom", sourceFrom);
             sparams[0].Direction = System.Data.ParameterDirection.Input;
             return(context.ExecuteSproc <CurrencySource>("usp_GetCurrencySources", sparams));
         }
         else
         {
             return(context.ExecuteSproc <CurrencySource>("usp_GetCurrencySources"));
         }
     }
 }
Ejemplo n.º 5
0
 internal CurrencySourceLists(bool activeOnly)
 {
     this.ActiveOnly = activeOnly;
     //get full list from db
     using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
     {
         this.FullCurrencyList = context.ExecuteSproc <CurrencySource>("usp_GetCurrencySources").Where(c => c.Active = (this.ActiveOnly) ? true : c.Active);
     }
 }
Ejemplo n.º 6
0
 internal IEnumerable <CurrencySource> GetListOfToCurrencies(string fromSource, string baseCurrency)
 {
     using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
     {
         SqlParameter[] sparams = new SqlParameter[2];
         sparams[0] = new SqlParameter("SourceFrom", fromSource);
         sparams[1] = new SqlParameter("BaseToUse", baseCurrency);
         return(context.ExecuteSproc <CurrencySource>("usp_GetCurrencySourcesTo", sparams));
     }
 }
Ejemplo n.º 7
0
        public string GetUserIDByCookieID(string cookieID)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0] = new SqlParameter("SessionID", cookieID);

                return(context.ExecuteSproc <string>("usp_GetUserIDByCookie", sparams).FirstOrDefault());
            }
        }
Ejemplo n.º 8
0
        public UserEntity GetUser(string userName)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0] = new SqlParameter("UserName", userName);

                return(context.ExecuteSproc <UserEntity>("usp_GetUser", sparams).FirstOrDefault());
            }
        }
Ejemplo n.º 9
0
        public IEnumerable <CurrencyEntity> GetFor(string forParameter)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0] = new SqlParameter("CurrencySelected", forParameter);

                return(context.ExecuteSproc <CurrencyEntity>("usp_GetAllowedCurrencies", sparams));
            }
        }
Ejemplo n.º 10
0
        public bool CheckUserName(string username)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0] = new SqlParameter("UserName", username);

                int result = context.ExecuteSproc <int>("usp_CheckUserName", sparams).FirstOrDefault();
                return((result == 1) ? true : false);
            }
        }
Ejemplo n.º 11
0
        public EmailAlertEntity GetAlert(int alertID)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0]           = new SqlParameter("AlertID", SqlDbType.Int);
                sparams[0].Direction = System.Data.ParameterDirection.Input;
                sparams[0].Value     = alertID;

                return(context.ExecuteSproc <EmailAlertEntity>("usp_GetEmailAlert", sparams).FirstOrDefault());
            }
        }
Ejemplo n.º 12
0
        public IEnumerable <CurrencyRateEntity> GetRatesForCurrency(string currencyCd, bool fromToOnly)
        {
            //return this.EntityData.Where(e => e.FromCurrency == currencyCd || e.ToCurrency == currencyCd);
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[2];
                sparams[0] = new SqlParameter("Currency", currencyCd);
                sparams[1] = new SqlParameter("GetOnlyFromTo", fromToOnly);

                return(context.ExecuteSproc <CurrencyRateEntity>("usp_GetCurrencyRatesUsingCurrency", sparams));
            }
        }
Ejemplo n.º 13
0
        public CurrencyRateEntity GetSingle(string fromCurrencyCd, string toCurrencyCd)
        {
            //return this.EntityData.SingleOrDefault(e => e.FromCurrency == fromCurrencyCd && e.ToCurrency == toCurrencyCd);
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[2];
                sparams[0] = new SqlParameter("CurrencyFrom", fromCurrencyCd);
                sparams[1] = new SqlParameter("CurrencyTo", toCurrencyCd);

                return(context.ExecuteSproc <CurrencyRateEntity>("usp_GetCurrencyRatesForPair", sparams).FirstOrDefault());
            }
        }
Ejemplo n.º 14
0
        public IEnumerable <RateHistoryEntity> GetHistoricalRatesFor(string currencyFrom, string currencyTo, DateTime dateFrom, DateTime dateTo)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[4];
                sparams[0] = new SqlParameter("CurrencyFrom", currencyFrom);
                sparams[1] = new SqlParameter("CurrencyTo", currencyTo);
                sparams[2] = new SqlParameter("DateFrom", dateFrom);
                sparams[3] = new SqlParameter("DateTo", dateTo);

                return(context.ExecuteSproc <RateHistoryEntity>("usp_GetHistoricalCurrencyRates", sparams));
            }
        }
Ejemplo n.º 15
0
        public bool ValidateUser(string username, string password)
        {
            using (var context = new DataAccessFramework.DBConnection.DBConnectionContext(DatabaseName.CuMaster))
            {
                SqlParameter[] sparams = new SqlParameter[1];
                sparams[0] = new SqlParameter("UserName", username);

                UserAuthEntity u = context.ExecuteSproc <UserAuthEntity>("usp_GetUserCredentals", sparams).FirstOrDefault();

                if (Security.PasswordHash.ValidatePassword(password, u.Hash))
                {
                    return(true);
                }
            }

            return(false);
        }