コード例 #1
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);
        }
コード例 #2
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;
        }
コード例 #3
0
        public UserStatisticSettings GetOrCreateUserSettings(string loginName)
        {
            UserStatisticSettings settings = new UserStatisticSettings();
             var userRepository = new UsersRepository();
             var user = userRepository.GetUserByLoginName(loginName);

             if (user != null)
             {
            var settingsRepository = new StatisticConfigurationRepository();
            settings = settingsRepository.GetUserStatisticSettingsByUserId(user.UserId);

            if (settings == null)
            {
               var newSettings = new UserStatisticSettings();
               newSettings.UserId = user.UserId;

               bool isSuccess = settingsRepository.AddUserStatisticSettings(newSettings);
               settings = newSettings;
            }

             }
             return settings;
        }
コード例 #4
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;
        }
コード例 #5
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");
        }