public ActionResult DeleteAccount(int accountId) { var accountRepository = new AccountRepository(); accountRepository.DeleteAccount(accountId); return Json(true); }
public ActionResult EditAccount(int id) { AccountData accountData = new AccountData(); AccountRepository accountRepository = new AccountRepository(); var account = accountRepository.GetAccountById(id); if (account != null) accountData = account; return View("EditAccount", account); }
public ActionResult ManageAccounts() { var userRepository = new UsersRepository(); var user = userRepository.GetUserByLoginName(User.Identity.Name); List<AccountData> accounts = new List<AccountData>(); if (user != null) { var accountRepository = new AccountRepository(); accounts = accountRepository.GetAccountsByUserId(user.UserId); } return View(accounts); }
public void FillUserStatistic(int accountId, ShortStatistic toFill, Statistic graphModel) { var depositsRepository = new DepositsDataRepository(); var deposits = depositsRepository.GetDepositsDataByUserId(accountId).ToList(); var accountRepository = new AccountRepository(); var account = accountRepository.GetAccountById(accountId); if (account != null) { toFill.Broker = account.Broker; toFill.Leverage = account.Leverage; toFill.StartedDate = account.Date ?? DateTime.Now; toFill.System = account.System; toFill.TimeZone = account.TimeZone ?? 0; toFill.Trading = account.Trading; toFill.Type = account.Type; toFill.Views = account.Views ?? 0; toFill.Desctiption = account.Desctiption; } if (deposits.Count != 0) { var sortedByDate = deposits.OrderBy(x => x.Date); var sortedDepositesOnly = sortedByDate.Where(x => x.IncomeType == DataType.Deposit); decimal startValue = sortedDepositesOnly.First().Amount; decimal endValue = sortedDepositesOnly.Last().Amount; toFill.Deposits = startValue; decimal maxAmount = sortedDepositesOnly.Max(x => x.Amount); var highestEntity = sortedDepositesOnly.FirstOrDefault(x => x.Amount == maxAmount); if (highestEntity != null) { toFill.Highest = highestEntity.Amount; toFill.HighestDate = highestEntity.Date; } decimal defference = endValue - startValue; decimal value = startValue != 0 ? (defference / startValue) * 100 : 0; toFill.AbsGain = value; FillGraphData(sortedByDate.ToList(), graphModel, toFill); } }
public UserStatisticSettings GetAccountSettings(int accountId) { var settings = new UserStatisticSettings(); var accountRepository = new AccountRepository(); var account = accountRepository.GetAccountById(accountId); if (account != null) { var userRepository = new UsersRepository(); var user = userRepository.GetUserById(account.UserId); settings = GetOrCreateUserSettings(user.LoweredUserName); } return settings; }
public bool IsAccountExist(int accountId) { var accountRepository = new AccountRepository(); var account = accountRepository.GetAccountById(accountId); return account != null; }
public void IncrementViews(int accountId) { var repository = new AccountRepository(); repository.IncrementViewsById(accountId); }
public string GetUserNameByAccountId(int accountId) { string userName = string.Empty; var accountRepository = new AccountRepository(); var account = accountRepository.GetAccountById(accountId); if (account != null) { var userRepository = new UsersRepository(); var user = userRepository.GetUserById(account.UserId); if (user != null) userName = user.UserName; } return userName; }
public ActionResult SaveAccount(AccountData account) { if (account != null) { AccountRepository accountRepository = new AccountRepository(); if (account.Id == 0) { UsersRepository repository = new UsersRepository(); var user = repository.GetUserByLoginName(User.Identity.Name); if (user != null) account.UserId = user.UserId; accountRepository.AddAcount(account); } else accountRepository.SaveAcount(account); } return RedirectToAction("ManageAccounts"); }