コード例 #1
0
        public ActionResult DeleteAccount(int accountId)
        {
            var accountRepository = new AccountRepository();
            accountRepository.DeleteAccount(accountId);

            return Json(true);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
             }
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        public bool IsAccountExist(int accountId)
        {
            var accountRepository = new AccountRepository();
             var account = accountRepository.GetAccountById(accountId);

             return account != null;
        }
コード例 #7
0
 public void IncrementViews(int accountId)
 {
     var repository = new AccountRepository();
      repository.IncrementViewsById(accountId);
 }
コード例 #8
0
        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;
        }
コード例 #9
0
        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");
        }