Exemple #1
0
        public static async Task <DatabaseResponse> GetPubicValue(string serviceCode, IConfiguration _configuration)
        {
            DataAccessHelper _DataHelper = null;

            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@ConfigType", SqlDbType.NVarChar)
                };

                parameters[0].Value = serviceCode;

                _DataHelper = new DataAccessHelper("Admin_GetPublicConfigurations", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt); // 102 /105

                DatabaseResponse response = new DatabaseResponse();

                if (result == 105)
                {
                    List <Dictionary <string, string> > configDictionary = new List <Dictionary <string, string> >();

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        configDictionary = LinqExtensions.GetDictionary(dt);
                    }

                    response = new DatabaseResponse {
                        ResponseCode = result, Results = configDictionary
                    };
                }

                else
                {
                    response = new DatabaseResponse {
                        ResponseCode = result
                    };
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Exemple #2
0
        public async Task <bool> AllowSubscribers(int CustomerID, int Type, IConfiguration _configuration)
        {
            bool             allowed     = false;
            DataAccessHelper _DataHelper = null;

            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CustomerID", SqlDbType.Int),
                    new SqlParameter("@Type",       SqlDbType.Int)
                };

                parameters[0].Value = CustomerID;
                parameters[1].Value = Type;
                _DataHelper         = new DataAccessHelper("Customers_IsAdditionalSubscriberAllowed", parameters, _configuration);

                int response = await _DataHelper.RunAsync();

                if (response == 140)
                {
                    allowed = true;
                }
                else
                {
                    allowed = false;
                }
            }

            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
            return(allowed);
        }
Exemple #3
0
        public async Task <DatabaseResponse> AuthenticateCustomerToken(string token, string source)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Token",  SqlDbType.NVarChar),
                    new SqlParameter("@Source", SqlDbType.NVarChar)
                };

                parameters[0].Value = token;
                parameters[1].Value = source;

                _DataHelper = new DataAccessHelper("Customer_AuthenticateTokenwithSource", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt); // 111 /109

                DatabaseResponse response = new DatabaseResponse();

                AuthTokenResponse tokenResponse = new AuthTokenResponse();

                if (result == 111)
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        tokenResponse = (from model in dt.AsEnumerable()
                                         select new AuthTokenResponse()
                        {
                            CustomerID = model.Field <int>("CustomerID"),

                            CreatedOn = model.Field <DateTime>("CreatedOn")
                        }).FirstOrDefault();
                    }

                    DatabaseResponse configResponse = ConfigHelper.GetValueByKey(ConfigKeys.CustomerTokenExpiryInDays.ToString(), _configuration);

                    if (configResponse.ResponseCode == (int)DbReturnValue.RecordExists)
                    {
                        if (tokenResponse.CreatedOn < DateTime.Now.AddDays(-int.Parse(configResponse.Results.ToString())))
                        {
                            tokenResponse.IsExpired = true;
                        }
                    }

                    response = new DatabaseResponse {
                        ResponseCode = result, Results = tokenResponse
                    };
                }

                else
                {
                    response = new DatabaseResponse {
                        ResponseCode = result
                    };
                }

                return(response);
            }

            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }