public async Task UpdateAccount(NxtAccount account) { using (var context = new WalletContext()) { context.NxtAccounts.Attach(account); context.Entry(account).State = EntityState.Modified; await context.SaveChangesAsync(); } }
public async Task SetUserReactionTipSetting(string slackId, bool value) { using (var context = new WalletContext()) { var setting = await context.UserSettings.SingleOrDefaultAsync(u => u.Account.SlackId == slackId && u.Key == reactionTipSettingKey); if (setting != null) { setting.Value = value.ToString(); context.Entry(setting).State = EntityState.Modified; } else { var account = await GetAccount(slackId); setting = new UserSetting { AccountId = account.Id, Key = reactionTipSettingKey, Value = value.ToString() }; context.Add(setting); } await context.SaveChangesAsync(); } }