Example #1
0
 public bool CheckValidVenviciUser(string username)
 {
     var venvici = new VenviciModel()
     {
         enumAction = VenviciAction.CheckGtoken,
         username = username
     };
     var result = SendAPIRequest(venvici);
     var suscess = result.Contains(Helper.GetDescription(VenviciReult.success));
     Api.Instance.LogApi("1", "web/checkGToken.jsp", suscess, HttpContext.Current.Request.UserAgent,
         "venvici", username, HttpContext.Current.Request.UserHostAddress, string.Empty, JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);
     return suscess;
 }
Example #2
0
 public bool AddMember(CustomerAccount user)
 {
     var venvici = new VenviciModel()
     {
         enumAction = VenviciAction.Addmember,
         username = user.username,
         email = user.email,
         password = user.unhashed_password,
         md5Password = user.password,
         introducerId = user.inviter_username,
         country = user.country_code
     };
     var result = SendAPIRequest(venvici);
     bool suscess = result.Contains(Helper.GetDescription(VenviciReult.success));
     Api.Instance.LogApi("1", "web/addMember.jsp", suscess, HttpContext.Current.Request.UserAgent,
        "venvici", user.username, HttpContext.Current.Request.UserHostAddress, string.Empty, JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);
     return suscess;
 }
Example #3
0
 /// <summary>
 /// Check to know if customer's amount is valid or not
 /// </summary>
 /// <param name="username"></param>
 /// <param name="amount"></param>
 /// <returns>TRUE: valid - FALSE: not valid</returns>
 public bool CheckGToken(string username, decimal amount)
 {
     var venvici = new VenviciModel()
     {
         enumAction = VenviciAction.CheckGtoken,
         username = username
     };
     var result = SendAPIRequest(venvici);
     bool suscess = result.Contains(Helper.GetDescription(VenviciReult.success));
     Api.Instance.LogApi("1", "web/checkGToken.jsp", suscess, HttpContext.Current.Request.UserAgent,
         "venvici", username, HttpContext.Current.Request.UserHostAddress, string.Empty, JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);
     if (suscess)
     {
         var arr = result.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
         decimal balance = 0;
         decimal.TryParse(arr[2], out balance);
         return amount <= balance;
     }
     return false;
 }
Example #4
0
 public bool PushBv(string username, Transaction transaction)
 {
     decimal pushbv = Math.Round(transaction.revenue * 0.1m, 2);
     var venvici = new VenviciModel()
     {
         enumAction = VenviciAction.PushBV,
         username = username,
         bv = pushbv
     };
     var result = SendAPIRequest(venvici);
     bool success = result.Contains(Helper.GetDescription(VenviciReult.success));
     Api.Instance.LogApi("1", "web/pushBv.jsp", success, HttpContext.Current.Request.UserAgent,
        "venvici", transaction.customer_username, HttpContext.Current.Request.UserHostAddress, string.Empty, JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);
     if (success)
     {
         string remark = string.Format("BV for transaction: {0}, originator: {1}", transaction.gtoken_transaction_id, transaction.customer_username);
         recordTransaction(username, transaction.gtoken_transaction_id, remark, pushBv: pushbv);
     }
     return success;
 }
Example #5
0
        public bool AddGToken(string username, string remark, decimal gtoken, string gtoken_transaction_id)
        {
            var venvici = new VenviciModel()
            {
                enumAction = VenviciAction.CreditInGT,
                username = username,
                amount = gtoken,
                remark = remark,
                refNo = gtoken_transaction_id
            };
            var result = SendAPIRequest(venvici);
            bool suscess = result.Contains(Helper.GetDescription(VenviciReult.success));
            if (suscess)
                recordTransaction(username, gtoken_transaction_id, remark, gtoken_add_amount: gtoken);

            Api.Instance.LogApi("1", "web/creditInGT.jsp", suscess, HttpContext.Current.Request.UserAgent,
               "venvici", username, HttpContext.Current.Request.UserHostAddress, string.Empty,
               JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);

            return suscess;
        }
Example #6
0
        public string SendAPIRequest(VenviciModel model)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["VENVICI_HOST"]);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                // HTTP POST
                List<KeyValuePair<string, string>> ValueCollection = new List<KeyValuePair<string, string>>();
                string action = string.Empty;
                switch (model.enumAction)
                {
                    case VenviciAction.Addmember:
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_USERNAME, model.username));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_EMAIL, model.email));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_PASSWORD, model.password));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_MD5PASSWORD, model.md5Password));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_INTRODUCERID, model.introducerId));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_COUNTRY, model.country));
                        action = Urls.VENVICI_ACTION_ADDMEMBER;
                        break;

                    case VenviciAction.CheckGtoken:
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_USERNAME, model.username));
                        action = Urls.VENVICI_ACTION_CHECKGTOKEN;
                        break;
                    case VenviciAction.CreditInCC:
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_USERNAME, model.username));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_AMOUNT, model.amount.ToString()));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_REFNO, model.refNo));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_REMARK, model.remark));
                        action = Urls.VENVICI_ACTION_CREDITINCC;
                        break;
                    case VenviciAction.deductGToken:
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_USERNAME, model.username));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_AMOUNT, model.amount.ToString()));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_REFNO, model.refNo));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_REMARK, model.remark));
                        action = Urls.VENVICI_ACTION_DEDUCTGTOKEN;
                        break;
                    case VenviciAction.PushBV:
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_USERNAME, model.username));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_BV, model.bv.ToString()));
                        action = Urls.VENVICI_ACTION_PUSHBV;
                        break;
                    case VenviciAction.CreditInGT:
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_USERNAME, model.username));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_AMOUNT, model.amount.ToString()));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_REFNO, model.refNo));
                        ValueCollection.Add(new KeyValuePair<string, string>(ConstantValues.S_REMARK, model.remark));
                        action = Urls.VENVICI_ACTION_CREDITINGT;
                        break;
                    default:
                        break;
                }
                var formContent = new FormUrlEncodedContent(ValueCollection);
                HttpResponseMessage response = client.PostAsync(action, formContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    return response.Content.ReadAsStringAsync().Result;
                }
                return string.Empty;
            }
        }
Example #7
0
 public bool deductGToken(string username, TokenTransaction transaction, string campTitle)
 {
     string remark = string.Format("Deduct GToken for transaction: {0} {1}, originator: {2}", transaction.gtoken_transaction_id, campTitle, transaction.customer_username);
     decimal amount = transaction.amount;
     var venvici = new VenviciModel()
     {
         enumAction = VenviciAction.deductGToken,
         username = username,
         amount = amount,
         refNo = transaction.gtoken_transaction_id,
         remark = remark
     };
     var result = SendAPIRequest(venvici);
     bool suscess = result.Contains(Helper.GetDescription(VenviciReult.success));
     Api.Instance.LogApi("1", "web/deductGToken.jsp", suscess, HttpContext.Current.Request.UserAgent,
        "venvici", transaction.customer_username, HttpContext.Current.Request.UserHostAddress, string.Empty,
        JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);
     if (suscess)
         recordTransaction(username, transaction.gtoken_transaction_id, remark, gtokenAmount: amount);
     return suscess;
 }
Example #8
0
 public bool commissionCredit(string username, Transaction transaction)
 {
     string remark = string.Format("Commission Credit for transaction: {0}, originator: {1}", transaction.gtoken_transaction_id, transaction.customer_username);
     var venvici = new VenviciModel()
     {
         enumAction = VenviciAction.CreditInCC,
         username = username,
         amount = transaction.revenue,
         refNo = transaction.gtoken_transaction_id,
         remark = remark
     };
     var result = SendAPIRequest(venvici);
     bool suscess = result.Contains(Helper.GetDescription(VenviciReult.success));
     Api.Instance.LogApi("1", "web/creditInCC.jsp", suscess, HttpContext.Current.Request.UserAgent,
        "venvici", transaction.customer_username, HttpContext.Current.Request.UserHostAddress, string.Empty,
        JsonConvert.SerializeObject(venvici) + " ---- Result: " + result);
     if (suscess)
         recordTransaction(username, transaction.gtoken_transaction_id, remark, commissionCredit: transaction.revenue);
     return suscess;
 }