本文整理汇总了C#中LBT.DAL.DefaultContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultContext.Entry方法的具体用法?C# DefaultContext.Entry怎么用?C# DefaultContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LBT.DAL.DefaultContext
的用法示例。
在下文中一共展示了DefaultContext.Entry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportBankTransactions
public static void ImportBankTransactions(DefaultContext db, out string bankToken, out string failedUrl)
{
bankToken = "Unknown";
failedUrl = "Unknown";
string bankTransactionUrlTemplate = Properties.Settings.Default.BankTransactionUrl;
string bankTransactionSetStartDateUrlTemplate = Properties.Settings.Default.BankTransactionSetStartDateUrl;
string bankTransactionSetStartIdUrlTemplate = Properties.Settings.Default.BankTransactionSetStartIdUrl;
BankAccount[] bankAccounts = GetValidAccounts(db);
foreach (BankAccount bankAccount in bankAccounts)
{
bankToken = bankAccount.Token;
InternetResponse internetResponse;
if (!bankAccount.LastDownloadId.HasValue)
{
string bankTransactionSetStartDateUrl = String.Format(bankTransactionSetStartDateUrlTemplate, bankAccount.Token, bankAccount.TransactionStartDate.ToString("yyyy-MM-dd"));
failedUrl = bankTransactionSetStartDateUrl;
internetResponse = InternetRequest.SendRequest(bankTransactionSetStartDateUrl, InternetRequestType.OnlyStatusCode);
}
else
{
string bankTransactionSetStartIdUrl = String.Format(bankTransactionSetStartIdUrlTemplate, bankAccount.Token, bankAccount.LastDownloadId.GetValueOrDefault());
failedUrl = bankTransactionSetStartIdUrl;
internetResponse = InternetRequest.SendRequest(bankTransactionSetStartIdUrl, InternetRequestType.OnlyStatusCode);
}
if (internetResponse.HttpStatusCode != HttpStatusCode.OK)
continue;
string bankTransactionUrl = String.Format(bankTransactionUrlTemplate, bankAccount.Token);
failedUrl = bankTransactionUrl;
BankAccountHistory[] bankAccountHistories;
Int64? lastDownloadId;
HttpStatusCode httpStatusCode = BankAccountHistoryCache.ProcessTransactionRequest(bankTransactionUrl, bankAccount.BankAccountId, out bankAccountHistories, out lastDownloadId);
if (httpStatusCode != HttpStatusCode.OK || bankAccountHistories.Length == 0)
continue;
foreach (BankAccountHistory bankAccountHistory in bankAccountHistories.Where(bah => bah.Ammount > 0))
{
db.BankAccountHistories.Add(bankAccountHistory);
string logMessage = String.Format("Imported bank transaction: account: {0}, date: {1}, ammount: {2}, exchange: {3}, ks: {4}, vs: {5}, ss: {6}", bankAccount.AccountId,bankAccountHistory.Date, bankAccountHistory.Ammount,bankAccountHistory.Exchange, bankAccountHistory.Ks,bankAccountHistory.Vs, bankAccountHistory.Ss);
Logger.SetLog(logMessage);
}
bankAccount.LastDownloadId = lastDownloadId;
db.Entry(bankAccount).State = EntityState.Modified;
}
db.SaveChanges();
}