public void Save() { using (var store = new DataStoreContext()) { store.ScreenSecurity.DeleteAllOnSubmit(store.ScreenSecurity.ToArray()); store.SubmitChanges(); store.ScreenSecurity.InsertAllOnSubmit(Items.Where(x => x.AccessLevel != AccessLevel.None)); store.SubmitChanges(); } App.Current.Security.LoadFromDatabase(); Navigator.GoBack(); }
protected override void ProcessResult(string response, bool hasError) { var result = JsonConvert.DeserializeObject<Account>(response); using (var store = new DataStoreContext()) { var account = store.Accounts.FirstOrDefault(x => x.AccountNumber == result.AccountNumber); var toDelete = account.TransactionList.Where(x => !AlreadyExists(result .Transactions, x)).ToArray(); var transactions = result .Transactions .Where(x => !AlreadyExists(account.TransactionList, x)).ToArray(); store.Transactions.DeleteAllOnSubmit(toDelete); foreach (var transaction in transactions.Reverse()) account.TransactionList.Add(transaction); store.SubmitChanges(); var action = transactions.Length + " new transactions found."; string more; if (transactions.Length == 1) more = string.Format("${0:0.00} {1}", transactions[0].AbsAmount, transactions[0].Summary); else { decimal amount = transactions.Sum(x => x.Amount); more = string.Format("Totalling ${0:0.00} {1}.", Math.Abs(amount), amount > 0 ? "in" : "out"); } Status.SetImportantAction(action, more, true); var template = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); } }
protected override void ProcessResult(string response, bool hasError) { var result = JsonConvert.DeserializeObject<TransferAccountResult>(response); foreach (var account in result.AccountsToLinked) { account.Type = TransferToAccount.AccountType.Linked; account.SenderId = result.AccountsFrom.Where(x => x.AccountNumber == account.AccountNumber).Select(x => x.Id).FirstOrDefault(); } foreach (var account in result.AccountsToNotLinked) account.Type = TransferToAccount.AccountType.ThirdParty; var accounts = result.AccountsToLinked.Union(result.AccountsToNotLinked); foreach (var account in accounts.Where(x => x.LastUsed == DateTime.MinValue)) account.LastUsed = new DateTime(2000, 1, 1); using (var store = new DataStoreContext()) { var inDatabase = store.TransferToAccounts.ToArray(); var toDelete = inDatabase.Where(x => !AlreadyExists(accounts, x)).ToArray(); var toInsert = accounts.Where(x => !AlreadyExists(inDatabase, x)).ToArray(); store.TransferToAccounts.DeleteAllOnSubmit(toDelete); store.TransferToAccounts.InsertAllOnSubmit(toInsert); store.SubmitChanges(); Status.SetAction("Accounts loaded", true); } }
void OnLogonFailed() { using (var store = new DataStoreContext()) { store.LoginDetails.DeleteAllOnSubmit(store.LoginDetails); store.SubmitChanges(); } Status.SetAction("Error occured while trying to log on", true); }
public void Delete() { if (!Existing) return; using (var store = new DataStoreContext()) { var data = store.Replacements.First(x => x.Id == Data.Id); store.Replacements.DeleteOnSubmit(data); store.SubmitChanges(); } Navigator.GoBack(); }
public void Save() { var encryptedPin = new TwoWayEncryption().Encrypt(Pin); using (var store = new DataStoreContext()) { var details = store.LoginDetails.First(); details.Pin = encryptedPin; store.SubmitChanges(); } Navigator.GoBack(); }
protected override void ProcessResult(string response, bool hasError) { var result = JsonConvert.DeserializeObject<UpcomingTransResult>(response); using (var store = new DataStoreContext()) { var toDelete = store.UpcomingTransactions.ToArray().Where(x => !AlreadyExists(result.Transactions, x)); var toInsert = result.Transactions.Where(x => !AlreadyExists(store.UpcomingTransactions, x)).ToArray(); store.UpcomingTransactions.DeleteAllOnSubmit(toDelete); store.UpcomingTransactions.InsertAllOnSubmit(toInsert); store.SubmitChanges(); Status.SetAction("Upcoming transactions found.", true); } }
void GlobalUnhandledExceptionHandler(object sender, ApplicationUnhandledExceptionEventArgs e) { if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break(); var error = new Error { Time = DateTime.Now, Message = e.ExceptionObject.Message, Extended = e.ExceptionObject.ToVerboseString() }; using (var store = new DataStoreContext()) { store.Errors.InsertOnSubmit(error); store.SubmitChanges(); } Status.SetAction("Unknown error occurred", true); e.Handled = true; }
void GlobalUnhandledExceptionHandler(object sender, ApplicationUnhandledExceptionEventArgs e) { if (Debugger.IsAttached) Debugger.Break(); var error = new Error { Time = DateTime.Now, Message = e.ExceptionObject.Message, Extended = e.ExceptionObject.ToVerboseString() }; using (var store = new DataStoreContext()) { store.Errors.InsertOnSubmit(error); store.SubmitChanges(); } e.Handled = true; NotifyComplete(); }
public void Save() { using (var store = new DataStoreContext()) { if (Existing) { var data = store.Replacements.First(x => x.Id == Data.Id); data.Original = Data.Original; data.NewValue = Data.NewValue; } else store.Replacements.InsertOnSubmit(Data); store.SubmitChanges(); Existing = true; } Navigator.GoBack(); }
public void MarkAsSeen() { using (var store = new DataStoreContext()) { foreach (var transaction in store.Transactions) transaction.IsSeen = true; store.SubmitChanges(); } Load(); }
public void Save() { if (SelectedAccount == null) return; using (var store = new DataStoreContext()) { if (store.Options.Any()) { store.CurrentOptions.SelectedAccountId = SelectedAccount.Id; store.CurrentOptions.AutoRefresh = AutoRefresh; } else store.Options.InsertOnSubmit(new Data.Options { SelectedAccountId = SelectedAccount.Id, AutoRefresh = AutoRefresh }); store.SubmitChanges(); var account = store.CurrentOptions.GetSelectedAccount(store); account.UseAvailableFunds = SelectedAccount.UseAvailableFunds; account.CreditLimit = SelectedAccount.CreditLimit; store.SubmitChanges(); } Navigator.GoBack(); }
public void SendErrorReport() { string message = ""; using (var store = new DataStoreContext()) { if (!store.Errors.Any()) return; message = store.Errors.ToArray().Select(x => x.ToString()).Aggregate((a, b) => a + "\n-----------\n\n" + b); store.Errors.DeleteAllOnSubmit(store.Errors); store.SubmitChanges(); } var emailComposeTask = new EmailComposeTask { Subject = "Bankr Error Report", Body = message, To = "*****@*****.**", }; emailComposeTask.Show(); }
void UpdateAccounts(string message) { var result = JsonConvert.DeserializeObject<LoginResult>(message); using (var store = new DataStoreContext()) { foreach (var account in result.AccountGroups.SelectMany(x => x.ListAccount)) { account.LastUpdate = DateTime.Now; var original = store.Accounts.FirstOrDefault(x => x.AccountNumber == account.AccountNumber); if (original == null) store.Accounts.InsertOnSubmit(account); else { original.Balance = account.Balance; original.AvailableFunds = account.AvailableFunds; original.LastUpdate = account.LastUpdate; } } store.SubmitChanges(); } SessionId = result.SID; }