private static CashSchedulerContext EmptySfDb( this CashSchedulerContext context, ISalesforceApiWebService salesforceService, IConfiguration configuration) { if (!bool.Parse(configuration["WebServices:SalesforceApi:SyncData"])) { return(context); } Console.WriteLine("Deleting all salesforce records..."); if (context.Categories.Any()) { salesforceService.DeleteSObjects( context.Categories.Select(t => new SfCategory(t.Id)).Cast <SfObject>().ToList() ).GetAwaiter().GetResult(); } if (context.Transactions.Any()) { salesforceService.DeleteSObjects( context.Transactions.Select(t => new SfTransaction(t.Id)).Cast <SfObject>().ToList() ).GetAwaiter().GetResult(); } if (context.RegularTransactions.Any()) { salesforceService.DeleteSObjects( context.RegularTransactions.Select(t => new SfRecurringTransaction(t.Id)).Cast <SfObject>().ToList() ).GetAwaiter().GetResult(); } if (context.Users.Any()) { salesforceService.DeleteSObjects( context.Users.Select(u => new SfContact(u.Id)).Cast <SfObject>().ToList() ).GetAwaiter().GetResult(); } return(context); }
private static CashSchedulerContext EmptyDb(this CashSchedulerContext context) { Console.WriteLine("Deleting all records..."); context.RegularTransactions.RemoveRange(context.RegularTransactions); context.Transactions.RemoveRange(context.Transactions); context.Categories.RemoveRange(context.Categories); context.TransactionTypes.RemoveRange(context.TransactionTypes); context.Settings.RemoveRange(context.Settings); context.Languages.RemoveRange(context.Languages); context.UserSettings.RemoveRange(context.UserSettings); context.UserNotifications.RemoveRange(context.UserNotifications); context.UserRefreshTokens.RemoveRange(context.UserRefreshTokens); context.UserEmailVerificationCodes.RemoveRange(context.UserEmailVerificationCodes); context.CurrencyExchangeRates.RemoveRange(context.CurrencyExchangeRates); context.Wallets.RemoveRange(context.Wallets); context.Currencies.RemoveRange(context.Currencies); context.Users.RemoveRange(context.Users); context.SaveChanges(); return(context); }
private static CashSchedulerContext ResetIdentitiesSeed(this CashSchedulerContext context) { Console.WriteLine("Resetting tables' identities...");