protected void btnAuthorizationMagento_Click(object sender, EventArgs e) { if (IsValid) { string url = txtMagentoStoreURL.Value.Trim(); string startSlash = string.Empty; if (url.EndsWith("/") == false) startSlash = "/"; if (url.StartsWith("http://") == false) url = "http://" + url; if (url.ToLower().Contains("index.php") == false) url += startSlash + "index.php/api/v2_soap/index/"; else url += startSlash + "api/v2_soap/index/"; string apiUserID = txtMagentoUserID.Value.Trim(); string apiKey = txtMagentoKey.Value.Trim(); bool isValid = new MagentoHelper(UserKey).TestMagentoCredentials(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 (hfSelectedMagentoAccountID.Value == "0") { UserAccount userAccount = new UserAccount(); userAccount.User_Code = UserKey; userAccount.Account_Code = (int)Constant.Accounts.Magento; 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(hfSelectedMagentoAccountID.Value); UserAccount userAccount = context.UserAccounts.First(u => u.Is_Active == true && u.Account_Code == (int)Constant.Accounts.Magento); userAccount.Application_Name = url; userAccount.Config_Value1 = apiUserID; userAccount.Config_Value2 = apiKey; userAccount.Modified_Date = DateTime.Now; userAccount.User_IP = Request.UserHostAddress; } context.SaveChanges(); magentoConnect.Style["display"] = "none"; magentoConnected.Style["display"] = "block"; lblMagentoError.Text = string.Empty; } else { lblMagentoError.Text = "URL or API credentials are not valid. Please check and try again"; } } }
public List<ParcelItem> GetMagentoTransactions(int UserCode) { MagentoHelper magentoService = new MagentoHelper(UserCode); return magentoService.GetPendingOrders(); }