public string DeactivateAll(int? userAccountCode, string categoryID, string searchColumn, string searchValue, int? country) { int userKey = new Base().UserKey; string query = "UPDATE SellerItem SET Is_Automated = 0 WHERE User_Code = " + userKey; DataModelEntities entities = new DataModelEntities(); entities.ExecuteStoreCommand(query); return GetPricingItems(null, userAccountCode, categoryID, searchColumn, searchValue, false, country); }
public string RemoveAccountToken(string type, int userAccountCode) { try { DataModelEntities context = new DataModelEntities(); UserAccount userAccount = null; int UserCode = new Base().UserKey; if (type == "EBAY") { userAccount = context.UserAccounts.First(f => f.User_Account_Code == userAccountCode); userAccount.Is_Active = false; } else if (type == "SHOPIFY") { userAccount = context.UserAccounts.First(f => f.User_Code == UserCode && f.Is_Active == true && f.Account_Code == (int)Constant.Accounts.Shopify); userAccount.Is_Active = false; } else if (type == "MAGENTO") { userAccount = context.UserAccounts.First(f => f.User_Code == UserCode && f.Is_Active == true && f.Account_Code == (int)Constant.Accounts.Magento); userAccount.Is_Active = false; } else if (type == "BIGCOMMERCE") { userAccount = context.UserAccounts.First(f => f.User_Code == UserCode && f.Is_Active == true && f.Account_Code == (int)Constant.Accounts.Bigcommerce); userAccount.Is_Active = false; } if (userAccount != null) { userAccountCode = userAccount.User_Account_Code; context.ExecuteStoreCommand("DELETE FROM ParcelItem WHERE AccountID = " + userAccountCode); context.ExecuteStoreCommand("DELETE FROM StockLedger WHERE AccountID = " + userAccountCode); context.ExecuteStoreCommand("DELETE FROM Items WHERE User_Account_Code = '" + userAccountCode + "'"); context.ExecuteStoreCommand("DELETE FROM SellerItemFile WHERE Item_Code IN (SELECT Item_Code FROM SellerItem Where User_Account_Code = " + userAccountCode + ")"); context.ExecuteStoreCommand("DELETE FROM PricingHistory WHERE Item_Code IN (SELECT Item_Code FROM SellerItem Where User_Account_Code = " + userAccountCode + ")"); context.ExecuteStoreCommand("DELETE FROM SellerItem WHERE User_Account_Code = " + userAccountCode); //context.SaveChanges(); // var parcelItems = context.ParcelItems.Where(w => w.AccountID == userAccountCode); // foreach (var item in parcelItems) // { // context.ParcelItems.DeleteObject(item); // } // string AccountID = userAccountCode.ToString(); // var legerItems = context.StockLedgers.Where(w => w.AccountID == AccountID); // foreach (var item in legerItems) // { // context.StockLedgers.DeleteObject(item); // } // var items = context.Items.Where(w => w.User_Account_Code == userAccountCode); // foreach (var item in items) // { // context.Items.DeleteObject(item); // } // var sellerItems = context.SellerItems.Where(w => w.User_Account_Code == userAccountCode); // foreach (var item in sellerItems) // { // var sellerItemsFiles = context.SellerItemFiles.Where(w => w.Item_Code == item.Item_Code); // foreach (var itemfiles in sellerItemsFiles) // { // context.SellerItemFiles.DeleteObject(itemfiles); // } // context.SellerItems.DeleteObject(item); // } } context.SaveChanges(); context = null; return "true"; } catch (Exception ex) { Logging.WriteLog(LogType.Critical, ex.ToString()); return null; } }