public bool DeleteAccount(int id) { using (var ctx = new forexBox2Entities()) { var account = ctx.AccountDatas.FirstOrDefault(x => x.Id == id); if (account != null) { var datas = ctx.DepositsDatas.Where(x => x.AccountId == id); foreach (var data in datas) { ctx.DeleteObject(data); } ctx.DeleteObject(account); } try { ctx.SaveChanges(); } catch { return false; } } return true; }
public void UpdateUserStatisticSettings(UserStatisticSettings settings) { using (var ctx = new forexBox2Entities()) { var entity = ctx.StatisticConfigurations.FirstOrDefault(x => x.UserId == settings.UserId); if (entity != null) { var data = SerializeObject(settings); entity.Data = data; ctx.SaveChanges(); } } }
public bool AddAcount(AccountData account) { using (var ctx = new forexBox2Entities()) { ctx.AccountDatas.AddObject(account); try { ctx.SaveChanges(); } catch { return false; } } return true; }
public void IncrementViewsById(int accountId) { using (var ctx = new forexBox2Entities()) { var account = ctx.AccountDatas.FirstOrDefault(x => x.Id == accountId); if (account != null) { account.Views = (account.Views == null) ? 1 : account.Views + 1; try { ctx.SaveChanges(); } catch { } } } }
public bool AddUserStatisticSettings(UserStatisticSettings settings) { using (var ctx = new forexBox2Entities()) { var data = SerializeObject(settings); ctx.StatisticConfigurations.AddObject(new StatisticConfiguration { Data = data, UserId = settings.UserId, }); try { ctx.SaveChanges(); } catch { return false; } } return true; }
public bool SaveAcount(AccountData account) { using (var ctx = new forexBox2Entities()) { var existAccount = ctx.AccountDatas.FirstOrDefault(x => x.Id == account.Id); if (existAccount != null) { existAccount.Broker = account.Broker; existAccount.Leverage = account.Leverage; existAccount.System = account.System; existAccount.Technical = account.Technical; existAccount.Trading = account.Trading; existAccount.Type = account.Trading; existAccount.Desctiption = account.Desctiption; try { ctx.SaveChanges(); } catch { return false; } } } return true; }