protected void btnAuthorizationBigcommerce_Click(object sender, EventArgs e) { if (IsValid) { string url = txtBigcommerceStoreURL.Value.Trim(); string startSlash = string.Empty; if (url.EndsWith("/") == false) startSlash = "/"; if (url.StartsWith("https://") == false) url = "https://" + url; url += startSlash + "api/v2"; string apiUserID = txtBigcommerceUserID.Value.Trim(); string apiKey = txtBigcommerceKey.Value.Trim(); // test provided credentials bool isValid = new BigcommerceHelper(UserKey).TestBigcommerceCredential(url, apiUserID, apiKey); if (isValid == true) { // save entry in database. DataModelEntities context = new DataModelEntities(); // check if user is creating a new account, or updating existing one if (hfSelectedBigcommerceAccountID.Value == "0") { UserAccount userAccount = new UserAccount(); userAccount.User_Code = UserKey; userAccount.Account_Code = (int)Constant.Accounts.Bigcommerce; userAccount.Application_Name = url; userAccount.Config_Value1 = apiUserID; userAccount.Config_Value2 = apiKey; userAccount.Created_Date = DateTime.Now; userAccount.Is_Active = true; userAccount.User_IP = Request.UserHostAddress; context.UserAccounts.AddObject(userAccount); } else { int userAccountCode = Convert.ToInt32(hfSelectedBigcommerceAccountID.Value); UserAccount userAccount = context.UserAccounts.First(u => u.Is_Active == true && u.Account_Code == (int)Constant.Accounts.Bigcommerce); userAccount.Application_Name = url; userAccount.Config_Value1 = apiUserID; userAccount.Config_Value2 = apiKey; userAccount.Modified_Date = DateTime.Now; userAccount.User_IP = Request.UserHostAddress; } context.SaveChanges(); bigcommerceConnect.Style["display"] = "none"; bigcommerceConnected.Style["display"] = "block"; bigcommerceError.Text = string.Empty; txtBigcommerceStoreURL.Value = ""; txtBigcommerceUserID.Value = ""; txtBigcommerceKey.Value = ""; } else { bigcommerceError.Text = "URL or API credentials are not valid. Please check and try again"; } } }
public List<ParcelItem> GetBigcommerceTransactions(int UserCode) { BigcommerceHelper bigcommerceService = new BigcommerceHelper(UserCode); return bigcommerceService.GetPendingOrders(); }