예제 #1
0
        public ApplicationService(IAccountsService accounts)
        {
            Accounts = accounts;

            _timer = new Timer(1000 * 60 * 45); // 45 minutes
            _timer.AutoReset = true;
            _timer.Elapsed += (sender, e) => {
                if (Account == null)
                    return;

                try
                {
                    var ret = Client.RefreshToken(LoginViewModel.ClientId, LoginViewModel.ClientSecret, Account.RefreshToken);
                    if (ret == null)
                        return;

                    Account.RefreshToken = ret.RefreshToken;
                    Account.Token = ret.AccessToken;
                    accounts.Update(Account);

                    UsersModel userInfo;
                    Client = Client.BearerLogin(Account.Token, out userInfo);
                }
                catch
                {
                    // Do nothing....
                }
            };
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 public TestConnectionManager(
     IAccountsService accountsService,
     IProjectsService projectsService,
     ITemplatesService templateService,
     ICacheManager cacheManager) : base(accountsService, projectsService, templateService, cacheManager)
 {
 }
예제 #3
0
        public TradingViewModel(ViewModelContext viewModelContext,
                                AccountViewModel accountViewModel, SymbolsViewModel symbolsViewModel,
                                TradeViewModel tradeViewModel, OrdersViewModel ordersViewModel,
                                IWpfExchangeService exchangeService, IAccountsService accountsService,
                                IChartHelper chartHelper)
            : base(viewModelContext)
        {
            AccountViewModel = accountViewModel;
            SymbolsViewModel = symbolsViewModel;
            TradeViewModel   = tradeViewModel;
            OrdersViewModel  = ordersViewModel;

            Symbols = new ObservableCollection <SymbolViewModel>();
            symbolObservableSubscriptions = new Dictionary <string, IDisposable>();

            this.exchangeService = exchangeService;
            this.accountsService = accountsService;
            this.chartHelper     = chartHelper;

            ObserveSymbols();
            ObserveAccount();
            ObserveTrade();
            ObserveOrders();

            CloseCommand = new ViewModelCommand(Close);
        }
예제 #4
0
        public ApplicationService(IAccountsService accounts)
        {
            Accounts = accounts;

            _timer           = new Timer(1000 * 60 * 45); // 45 minutes
            _timer.AutoReset = true;
            _timer.Elapsed  += (sender, e) => {
                if (Account == null)
                {
                    return;
                }

                try
                {
                    var ret = Client.RefreshToken(LoginViewModel.ClientId, LoginViewModel.ClientSecret, Account.RefreshToken);
                    if (ret == null)
                    {
                        return;
                    }

                    Account.RefreshToken = ret.RefreshToken;
                    Account.Token        = ret.AccessToken;
                    accounts.Update(Account);

                    UsersModel userInfo;
                    Client = Client.BearerLogin(Account.Token, out userInfo);
                }
                catch
                {
                    // Do nothing....
                }
            };
        }
예제 #5
0
 public TransactionService(IAccountsService accountsService, ITransactionsRepository transactionsRepository, IMapper mapper)
 {
     _accountsService        = accountsService;
     _transactionsRepository = transactionsRepository;
     _mapper = mapper;
     _transactionSemaphore = new SemaphoreSlim(1, 1);
 }
예제 #6
0
 public static async Task <string> GenerateAccessToken(
     IAccountsService accountsService,
     string userName,
     string ipAddress         = default,
     DateTime?creationDate    = default,
     string issuer            = default,
     string audience          = default,
     string signingKey        = default,
     double?durationInMinutes = default)
 {
     try
     {
         return((await accountsService.GenerateAccessTokenAsync(
                     userName: userName,
                     ipAddress: ipAddress ?? "127.0.0.1",
                     creationDate: creationDate ?? DateTime.UtcNow,
                     issuer: issuer,
                     audience: audience,
                     signingKey: signingKey,
                     durationInMinutes: durationInMinutes)).AccessToken);
     }
     catch (Exception ex)
     {
         throw new Exception($"Exception thrown on the test helper method 'GenerateAccessToken' with the message: {ex.Message}");
     }
 }
예제 #7
0
 public AccountController(
     IAccountsService accountService,
     SignInManager <ApplicationUser> signInManager)
 {
     _accountService = accountService;
     _signInManager  = signInManager;
 }
예제 #8
0
 public TransactionsController(
     ITransactionService transaction,
     IAccountsService account)
 {
     _transaction = transaction;
     _account     = account;
 }
 public AccountsTransactionMonitoringService(IAccountsService accountsService, IWeb3ProviderService web3ProviderService)
 {
     _accountsService     = accountsService;
     _web3ProviderService = web3ProviderService;
     _timer = Observable.Timer(TimeSpan.FromMilliseconds(500), _updateInterval, RxApp.MainThreadScheduler)
              .Select(_ => ProcessCompletedTransactions().ToObservable()).Concat().Subscribe();
 }
예제 #10
0
        private async Task attachUserToContext(HttpContext context, IAccountsService accountService, string token)
        {
            try
            {
                var tokenHandler = new JwtSecurityTokenHandler();
                var key          = Encoding.ASCII.GetBytes(_appSettings.Secret);
                tokenHandler.ValidateToken(token, new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false,
                    // set clockskew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later)
                    ClockSkew = TimeSpan.Zero
                }, out SecurityToken validatedToken);

                var jwtToken = (JwtSecurityToken)validatedToken;
                var email    = jwtToken.Claims.First(x => x.Type == "email").Value;

                // attach user to context on successful jwt validation
                context.Items["Account"] = await accountService.GetAccount(email);
            }
            catch
            {
                // do nothing if jwt validation fails
                // user is not attached to context so request won't have access to secure routes
            }
        }
예제 #11
0
 public AccountsTests(TinyBankFixture fixture)
 {
     _account = fixture.Scope.ServiceProvider
                .GetRequiredService <IAccountsService>();
     _customer = fixture.Scope.ServiceProvider
                 .GetRequiredService <ICustomerService>();
 }
예제 #12
0
 public AccountController(IAccountsService accountsService,
                          UserManager <User> userManager,
                          SignInManager <User> signInManager)
 {
     this.accountsService = accountsService;
     _userManager         = userManager;
 }
예제 #13
0
 public AccountsController(
     SignInManager <ApplicationUser> signInManager,
     IAccountsService accountsService)
 {
     _signInManager   = signInManager;
     _accountsService = accountsService;
 }
예제 #14
0
        public ProjectsViewModel(IApplicationService applicationService, IAccountsService accountsService)
        {
            Account            = accountsService.ActiveAccount;
            GoToProjectCommand = new ReactiveCommand();
            Projects           = new ReactiveCollection <Project>(new [] { CreatePersonalProject(accountsService.ActiveAccount) });

            LoadCommand.RegisterAsyncTask(async x =>
            {
                var getAllProjects = applicationService.StashClient.Projects.GetAll();

                using (Projects.SuppressChangeNotifications())
                {
                    Projects.Clear();
                    Projects.Add(CreatePersonalProject(accountsService.ActiveAccount));
                    Projects.AddRange(await getAllProjects.ExecuteAsyncAll());
                }
            });

            GoToProjectCommand.OfType <Project>().Subscribe(x =>
            {
                var vm        = this.CreateViewModel <RepositoriesViewModel>();
                vm.ProjectKey = x.Key;
                vm.Name       = x.Name;
                ShowViewModel(vm);
            });
        }
예제 #15
0
 public AccountsController(IAccountsService userService, IStudentsService studentsService, IParentsService parentsService, ITeachersService teachersService)
 {
     service = userService;
     this.studentsService = studentsService;
     this.parentsService  = parentsService;
     this.teachersService = teachersService;
 }
예제 #16
0
 public KraScoresController(IKraInputScoresService InputScoreService, IKraScoreCalculator ScoreCalculator, IExcelReportGenerator ReportGenerator, IAccountsService Account)
 {
     this.InputScoreService = InputScoreService;
     this.ScoreCalculator   = ScoreCalculator;
     this.ReportGenerator   = ReportGenerator;
     this.Account           = Account;
 }
예제 #17
0
        public ApplicationService(IAccountsService accountsService)
        {
            _accountsService = accountsService;

            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            accountsService.WhenAnyObservable(x => x.ActiveAccountChanged).StartWith(accountsService.ActiveAccount).Subscribe(account =>
            {
                if (account == null)
                {
                    Client       = null;
                    GitHubClient = null;
                }
                else
                {
                    var githubAccount = (GitHubAccount)account;
                    var domain        = githubAccount.Domain ?? Client.DefaultApi;
                    if (!string.IsNullOrEmpty(githubAccount.OAuth))
                    {
                        Client       = Client.BasicOAuth(githubAccount.OAuth, domain);
                        GitHubClient = new GitHubClient(new ProductHeaderValue("CodeHub"),
                                                        new InMemoryCredentialStore(new Credentials(githubAccount.OAuth)),
                                                        new Uri(domain));
                    }
                    else if (githubAccount.IsEnterprise || !string.IsNullOrEmpty(githubAccount.Password))
                    {
                        Client       = Client.Basic(githubAccount.Username, githubAccount.Password, domain);
                        GitHubClient = new GitHubClient(new ProductHeaderValue("CodeHub"),
                                                        new InMemoryCredentialStore(new Credentials(githubAccount.Username, githubAccount.Password)),
                                                        new Uri(domain));
                    }
                }
            });
        }
예제 #18
0
 public AccountController(
     IAccountsService accountsService,
     IMapper mapper)
 {
     _accountsService = accountsService;
     _mapper          = mapper;
 }
 public AccountSettingManager(IAccountsService accountsService,
                              IProjectsService projectsService,
                              ITemplatesService templateService,
                              ICacheManager cacheManager) : base(accountsService, projectsService, templateService, cacheManager)
 {
     _accountsRepository = new AccountsRepository();
 }
예제 #20
0
 public StartupViewModel(
     IApplicationService applicationService = null,
     IAccountsService accountsService       = null)
 {
     _applicationService = applicationService ?? GetService <IApplicationService>();
     _accountsService    = accountsService ?? GetService <IAccountsService>();
 }
예제 #21
0
 public AccountsController(IAccountsService accountsService, UserManager <User> userManager, SignInManager <User> signInManager, IMapper mapper)
 {
     this.accountsService = accountsService;
     this.userManager     = userManager;
     this.signInManager   = signInManager;
     this.mapper          = mapper;
 }
예제 #22
0
 public GetCustomerDetailQueryHandler(IApplicationDbContext context, IMapper mapper, IAccountsService accountsService, IHttpContextAccessor httpContextAccessor)
 {
     _context             = context;
     _mapper              = mapper;
     _accountsService     = accountsService;
     _httpContextAccessor = httpContextAccessor;
 }
예제 #23
0
        public AccountsViewModel(IAccountsService accountsService)
        {
            _accountsService = accountsService;
            Accounts = new ReactiveList<IAccount>(accountsService);
            LoginCommand = ReactiveCommand.Create();
            GoToAddAccountCommand = ReactiveCommand.Create();
            DeleteAccountCommand = ReactiveCommand.Create();

            DeleteAccountCommand.OfType<IAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    ActiveAccount = null;
                accountsService.Remove(x);
                Accounts.Remove(x);
            });

            LoginCommand.OfType<IAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    DismissCommand.ExecuteIfCan();
                else
                {
                    ActiveAccount = x;
                    MessageBus.Current.SendMessage(new LogoutMessage());
                    DismissCommand.ExecuteIfCan();
                }
            });

            GoToAddAccountCommand.Subscribe(_ => ShowViewModel(CreateViewModel<IAddAccountViewModel>()));

            this.WhenActivated(d => Accounts.Reset(accountsService));
        }
 public MeterReadingValidationService(
     IMetersRepository metersRepository,
     IAccountsService accountsService)
 {
     _MetersRepository = metersRepository;
     _AccountsService  = accountsService;
 }
예제 #25
0
 public AccountsTransactionMonitoringService(IAccountsService accountsService, IWeb3ProviderService web3ProviderService)
 {
     _accountsService     = accountsService;
     _web3ProviderService = web3ProviderService;
     _timer = Observable.Timer(TimeSpan.FromMilliseconds(500), _updateInterval, RxApp.MainThreadScheduler)
              .Subscribe(async _ => await ProcessCompletedTransactions().ConfigureAwait(false));
 }
예제 #26
0
        public LoginViewModel(IAccountsService accountsService)
        {
            LoginCommand = new ReactiveCommand(this.WhenAny(x => x.Username, x => x.Password, x => x.Domain, (u, p, d) =>
                                                            !string.IsNullOrEmpty(u.Value) && !string.IsNullOrEmpty(p.Value) && !string.IsNullOrEmpty(d.Value)));

            LoginCommand.RegisterAsyncTask(async x =>
            {
                var domain = Domain.TrimEnd('/');
                var client = AtlassianStashSharp.StashClient.CrateBasic(new Uri(domain), Username, Password);
                var info   = await client.Users[Username].Get().ExecuteAsync();

                var account = new Account {
                    Username = Username, Password = Password, Domain = domain
                };
                if (string.IsNullOrEmpty(account.AvatarUrl))
                {
                    var selfLink = info.Data.Links["self"].FirstOrDefault();
                    if (selfLink != null && !string.IsNullOrEmpty(selfLink.Href))
                    {
                        account.AvatarUrl = selfLink.Href + "/avatar.png";
                    }
                }

                accountsService.Insert(account);
                accountsService.ActiveAccount = account;
                LoggedInAcconut = account;
                MessageBus.Current.SendMessage(new LogoutMessage());
                //DismissCommand.ExecuteIfCan();
            });
        }
예제 #27
0
 public AccountsController(IAccountsService accountsService, SignInManager <User> signInManager,
                           UserManager <User> userManager)
 {
     _accountsService = accountsService;
     _signInManager   = signInManager;
     _userManager     = userManager;
 }
예제 #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="itemsRepository"></param>
        /// <param name="mappingRepository"></param>
        /// <param name="itemsService"></param>
        /// <param name="mappingManager"></param>
        /// <param name="importManager"></param>
        /// <param name="accountsService"></param>
        /// <param name="projectsService"></param>
        /// <param name="templateService"></param>
        /// <param name="cacheManager"></param>
        /// <param name="gcAccountSettings"></param>
        public UpdateManager(
            IItemsRepository itemsRepository,
            IMappingRepository mappingRepository,
            IItemsService itemsService,
            IMappingManager mappingManager,
            IImportManager importManager,
            IAccountsService accountsService,
            IProjectsService projectsService,
            ITemplatesService templateService,
            ICacheManager cacheManager,
            GCAccountSettings gcAccountSettings)
            : base(accountsService, projectsService, templateService, cacheManager)
        {
            ItemsRepository = itemsRepository;

            MappingRepository = mappingRepository;

            ItemsService = itemsService;

            MappingManager = mappingManager;

            ImportManager = importManager;

            GcAccountSettings = gcAccountSettings;
        }
예제 #29
0
        public TradingViewModel(ViewModelContext viewModelContext,
                                AccountViewModel accountViewModel,
                                SymbolsViewModel symbolsViewModel,
                                TradePanelViewModel tradePanelViewModel,
                                IWpfExchangeService exchangeService,
                                IAccountsService accountsService,
                                IOrderBookHelperFactory orderBookHelperFactory,
                                ITradeHelperFactory tradeHelperFactory,
                                IChartHelper chartHelper)
            : base(viewModelContext)
        {
            AccountViewModel = accountViewModel;
            SymbolsViewModel = symbolsViewModel;
            TradeViewModel   = tradePanelViewModel;

            this.exchangeService        = exchangeService;
            this.accountsService        = accountsService;
            this.orderBookHelperFactory = orderBookHelperFactory;
            this.tradeHelperFactory     = tradeHelperFactory;
            this.chartHelper            = chartHelper;

            ObserveSymbols();
            ObserveAccount();
            ObserveTrade();
        }
예제 #30
0
 public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signinManager,
                          IAccountsService accountsService)
 {
     _userManager     = userManager ?? throw new ArgumentNullException(nameof(userManager));
     _signinManager   = signinManager ?? throw new ArgumentNullException(nameof(signinManager));
     _accountsService = accountsService ?? throw new ArgumentNullException(nameof(accountsService));
 }
예제 #31
0
 public CouplesController()
 {
     _accountService     = new AccountsService();
     _coupleService      = new CouplesService();
     _personService      = new PersonsService();
     _presentListService = new PresentListService();
 }
예제 #32
0
 public LoginService(
     IAccountsService accountsService,
     IApplicationService applicationService)
 {
     _accountsService    = accountsService;
     _applicationService = applicationService;
 }
예제 #33
0
 public ErrorService(IHttpClientService httpClient, IJsonSerializationService jsonSerialization, IEnvironmentService environmentService, IAccountsService accountsService)
 {
     _jsonSerialization = jsonSerialization;
     _environmentService = environmentService;
     _accountsService = accountsService;
     _httpClient = httpClient.Create();
     _httpClient.Timeout = new TimeSpan(0, 0, 10);
     _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 }
예제 #34
0
 public ApplicationService(IAccountsService accounts, IMvxViewDispatcher viewDispatcher, 
     IFeaturesService features, IPushNotificationsService pushNotifications,
     IAlertDialogService alertDialogService)
 {
     _viewDispatcher = viewDispatcher;
     _pushNotifications = pushNotifications;
     Accounts = accounts;
     _features = features;
     _alertDialogService = alertDialogService;
 }
예제 #35
0
        public LoginViewModel(IApplicationService applicationService, IAccountsService accountsService)
		{
            _applicationService = applicationService;
            _accountsService = accountsService;

            LoginCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.Code).Select(x => x != null),
                t => Login());

            LoginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
		}
 public PersonalCabinetController(
     IUsersService usersService,
     IAccountsService accountsService,
     ITradingSystemService tradingSystemService,
     IStatService statService)
 {
     _usersService = usersService;
     _accountsService = accountsService;
     _tradingSystemService = tradingSystemService;
     _statService = statService;
 }
예제 #37
0
        public StartupViewModel(IAccountsService accountsService, ILoginService loginService)
        {
            _accountsService = accountsService;
            _loginService = loginService;

            GoToMainCommand = ReactiveCommand.Create().WithSubscription(_ => ShowViewModel(CreateViewModel<MenuViewModel>()));
            GoToAccountsCommand = ReactiveCommand.Create().WithSubscription(_ => ShowViewModel(CreateViewModel<AccountsViewModel>()));
            GoToNewUserCommand = ReactiveCommand.Create().WithSubscription(_ => ShowViewModel(CreateViewModel<NewAccountViewModel>()));
            BecomeActiveWindowCommand = ReactiveCommand.Create();

            LoadCommand = ReactiveCommand.CreateAsyncTask(x => Load());
        }
예제 #38
0
        protected BaseMenuViewModel(IAccountsService accountsService)
        {
            AccountsService = accountsService;
            DeletePinnedRepositoryCommand = ReactiveCommand.Create();
            PinnedRepositories = new ReactiveList<PinnedRepository>(AccountsService.ActiveAccount.PinnnedRepositories);

            DeletePinnedRepositoryCommand.OfType<PinnedRepository>()
                .Subscribe(x =>
                {
                    AccountsService.ActiveAccount.PinnnedRepositories.Remove(x);
                    AccountsService.Update(AccountsService.ActiveAccount);
                    PinnedRepositories.Remove(x);
                });
        }
예제 #39
0
        public LoginViewModel(ILoginService loginFactory, 
                              IAccountsService accountsService)
        {
            _loginFactory = loginFactory;

            WebDomain = "https://github.com";

            GoToOldLoginWaysCommand = new ReactiveCommand();
            GoToOldLoginWaysCommand.Subscribe(_ => ShowViewModel(CreateViewModel<AddAccountViewModel>()));

            LoginCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Code, x => !string.IsNullOrEmpty(x)));
            LoginCommand.RegisterAsyncTask(_ => Login(Code))
                .Subscribe(x => accountsService.ActiveAccount = x);
        }
예제 #40
0
        public AddAccountViewModel(ILoginService loginFactory, IAccountsService accountsService)
        {
            _loginFactory = loginFactory;

            this.WhenAnyValue(x => x.AttemptedAccount).Where(x => x != null).Subscribe(x =>
            {
                Username = x.Username;
                Password = x.Password;
                Domain = x.Domain;
            });

            LoginCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Username, y => y.Password, (x, y) => !string.IsNullOrEmpty(x) && !string.IsNullOrEmpty(y)));
            LoginCommand.RegisterAsyncTask(_ => Login())
                .Subscribe(x => accountsService.ActiveAccount = x);
        }
예제 #41
0
        public SettingsViewModel(IApplicationService applicationService, IFeaturesService featuresService, 
                                 IDefaultValueService defaultValueService, IAccountsService accountsService,
                                 IAnalyticsService analyticsService)
        {
            _applicationService = applicationService;
            _featuresService = featuresService;
            _defaultValueService = defaultValueService;
            _accountsService = accountsService;
            _analyticsService = analyticsService;

            GoToDefaultStartupViewCommand = new ReactiveCommand();
            GoToDefaultStartupViewCommand.Subscribe(_ => ShowViewModel(CreateViewModel<DefaultStartupViewModel>()));

            DeleteAllCacheCommand = new ReactiveCommand();
        }
예제 #42
0
 public AccountsViewModel(IAccountsService accountsService) 
 {
     SelectAccountCommand.OfType<BitbucketAccount>().Subscribe(x =>
     {
         if (accountsService.ActiveAccount?.Id == x.Id)
         {
             DismissCommand.ExecuteIfCan();
         }
         else
         {
             accountsService.SetActiveAccount(x);
             MessageBus.Current.SendMessage(new LogoutMessage());
         }
     });
 }
예제 #43
0
        public LoginViewModel(ILoginService loginFactory, 
                              IAccountsService accountsService)
        {
            _loginFactory = loginFactory;

            WebDomain = "https://github.com";

            GoToOldLoginWaysCommand = ReactiveCommand.Create();
            GoToOldLoginWaysCommand.Subscribe(_ => ShowViewModel(CreateViewModel<AddAccountViewModel>()));

            var loginCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.Code).Select(x => !string.IsNullOrEmpty(x)), _ => Login(Code));
            loginCommand.Subscribe(x => accountsService.ActiveAccount = x);
            loginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
            LoginCommand = loginCommand;
        }
        protected DefaultStartupViewModel(IAccountsService accountsService, Type menuViewModelType)
        {
            AccountsService = accountsService;

            SelectedStartupView = AccountsService.ActiveAccount.DefaultStartupView;
            this.WhenAnyValue(x => x.SelectedStartupView).Skip(1).Subscribe(x =>
            {
                AccountsService.ActiveAccount.DefaultStartupView = x;
                AccountsService.Update(AccountsService.ActiveAccount);
                DismissCommand.ExecuteIfCan();
            });

            StartupViews = new ReactiveList<string>(from p in menuViewModelType.GetRuntimeProperties()
                let attr = p.GetCustomAttributes(typeof(PotentialStartupViewAttribute), true).ToList()
                where attr.Count == 1 && attr[0] is PotentialStartupViewAttribute
                select ((PotentialStartupViewAttribute)attr[0]).Name);
        }
예제 #45
0
        public StartupViewModel(IAccountsService accountsService, IAccountValidatorService accountValidator)
        {
            AccountsService = accountsService;
            AccountValidator = accountValidator;

            GoToMainCommand = ReactiveCommand.Create();
            GoToAccountsCommand = ReactiveCommand.Create();
            GoToNewUserCommand = ReactiveCommand.Create();
            BecomeActiveWindowCommand = ReactiveCommand.Create();

            GoToAccountsCommand.Subscribe(_ => ShowViewModel(CreateViewModel<AccountsViewModel>()));

            GoToNewUserCommand.Subscribe(_ => ShowViewModel(CreateViewModel<IAddAccountViewModel>()));

            GoToMainCommand.Subscribe(_ => ShowViewModel(CreateViewModel<IMainViewModel>()));

            LoadCommand = ReactiveCommand.CreateAsyncTask(x => Load());
        }
예제 #46
0
        public AddAccountViewModel(ILoginService loginFactory, IAccountsService accountsService)
        {
            _loginFactory = loginFactory;

            this.WhenAnyValue(x => x.AttemptedAccount).Where(x => x != null).Subscribe(x =>
            {
                Username = x.Username;
                Password = x.Password;
                Domain = x.Domain;
            });

            var loginCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.Username, y => y.Password, (x, y) => !string.IsNullOrEmpty(x) && !string.IsNullOrEmpty(y)),
                _ => Login());
            loginCommand.Subscribe(x => accountsService.ActiveAccount = x);
            loginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
            LoginCommand = loginCommand;
        }
예제 #47
0
        public AccountsViewModel(IAccountsService accountsService)
        {
            _accountsService = accountsService;

            _accounts = new ReactiveList<GitHubAccount>(accountsService.OrderBy(x => x.Username));
            this.WhenActivated(d => _accounts.Reset(accountsService.OrderBy(x => x.Username)));
            Accounts = _accounts.CreateDerivedCollection(CreateAccountItem);

            this.WhenAnyValue(x => x.ActiveAccount)
                .Subscribe(x =>
                {
                    foreach (var account in Accounts)
                        account.Selected = Equals(account.Account, x);
                });

            DeleteAccountCommand = ReactiveCommand.Create();
            DeleteAccountCommand.OfType<GitHubAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    ActiveAccount = null;
                accountsService.Remove(x);
                _accounts.Remove(x);
            });

            LoginCommand = ReactiveCommand.Create();
            LoginCommand.OfType<GitHubAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    DismissCommand.ExecuteIfCan();
                else
                {
                    ActiveAccount = x;
                    MessageBus.Current.SendMessage(new LogoutMessage());
                    DismissCommand.ExecuteIfCan();
                }
            });

            DismissCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.ActiveAccount).Select(x => x != null))
                                            .WithSubscription(x => base.DismissCommand.ExecuteIfCan(x));

            GoToAddAccountCommand = ReactiveCommand.Create()
                .WithSubscription(_ => ShowViewModel(CreateViewModel<NewAccountViewModel>()));

        }
 protected BaseAccountsViewModel(IAccountsService accountsService)
 {
     _accountsService = accountsService;
 }
예제 #49
0
		public DefaultStartupViewModel(IAccountsService accountsService)
			: base(accountsService, typeof(MenuViewModel))
		{
		}
예제 #50
0
 public AccountsViewModel(IAccountsService accountsService) 
 {
     _accountsService = accountsService;
 }
예제 #51
0
		public DefaultStartupViewModel(IAccountsService accountsService)
		{
            _accountsService = accountsService;
            _menuViewModelType = typeof(MenuViewModel);
		}
 protected BaseDefaultStartupViewModel(IAccountsService accountsService, Type menuViewModelType)
 {
     _accountsService = accountsService;
     _menuViewModelType = menuViewModelType;
 }
예제 #53
0
 public LoginFactory(IAccountsService accounts)
 {
     _accounts = accounts;
 }
예제 #54
0
		public StartupViewModel(IAccountsService accountsService, IApplicationService applicationService)
		{
            _accountsService = accountsService;
			_applicationService = applicationService;
		}
예제 #55
0
 public LoginService(IAccountsService accounts)
 {
     _accounts = accounts;
 }
예제 #56
0
 public AccountsViewModel(IAccountsService accountsService, ILoginFactory loginFactory, IApplicationService applicationService) 
     : base(accountsService)
 {
     _loginFactory = loginFactory;
     _applicationService = applicationService;
 }
예제 #57
0
        public LoginViewModel(IAccountsService accountsService)
		{
            _accountsService = accountsService;
		}
예제 #58
0
 public AccountsViewModel(IAccountsService accountsService, ILoginService loginService, IApplicationService applicationService) 
     : base(accountsService)
 {
     _loginService = loginService;
     _applicationService = applicationService;
 }
예제 #59
0
        public MenuViewModel(IApplicationService applicationService, IAccountsService accountsService)
            : base(accountsService)
        {
            _applicationService = applicationService;

            GoToNotificationsCommand = new ReactiveCommand();
            GoToNotificationsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<NotificationsViewModel>();
                ShowViewModel(vm);
            });

            GoToAccountsCommand = new ReactiveCommand();
            GoToAccountsCommand.Subscribe(_ => CreateAndShowViewModel<AccountsViewModel>());

            GoToProfileCommand = new ReactiveCommand();
            GoToProfileCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<ProfileViewModel>();
                vm.Username = Account.Username;
                ShowViewModel(vm);
            });

            GoToMyIssuesCommand = new ReactiveCommand();
            GoToMyIssuesCommand.Subscribe(_ => CreateAndShowViewModel<MyIssuesViewModel>());

            GoToUpgradesCommand = new ReactiveCommand();
            GoToUpgradesCommand.Subscribe(_ => CreateAndShowViewModel<UpgradesViewModel>());

            GoToAboutCommand = new ReactiveCommand();
            GoToAboutCommand.Subscribe(_ => CreateAndShowViewModel<AboutViewModel>());

            GoToRepositoryCommand = new ReactiveCommand();
            GoToRepositoryCommand.OfType<RepositoryIdentifier>().Subscribe(x =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = x.Owner;
                vm.RepositoryName = x.Name;
                ShowViewModel(vm);
            });

            GoToSettingsCommand = new ReactiveCommand();
            GoToSettingsCommand.Subscribe(_ => CreateAndShowViewModel<SettingsViewModel>());

            GoToNewsCommand = new ReactiveCommand();
            GoToNewsCommand.Subscribe(_ => CreateAndShowViewModel<NewsViewModel>());

            GoToOrganizationsCommand = new ReactiveCommand();
            GoToOrganizationsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<OrganizationsViewModel>();
                vm.Username = Account.Username;
                ShowViewModel(vm);
            });

            GoToTrendingRepositoriesCommand = new ReactiveCommand();
            GoToTrendingRepositoriesCommand.Subscribe(_ => CreateAndShowViewModel<RepositoriesTrendingViewModel>());

            GoToExploreRepositoriesCommand = new ReactiveCommand();
            GoToExploreRepositoriesCommand.Subscribe(_ => CreateAndShowViewModel<RepositoriesExploreViewModel>());

            GoToOrganizationEventsCommand = new ReactiveCommand();
            GoToOrganizationEventsCommand.OfType<string>().Subscribe(name =>
            {
                var vm = CreateViewModel<UserEventsViewModel>();
                vm.Username = name;
                ShowViewModel(vm);
            });

            GoToOrganizationCommand = new ReactiveCommand();
            GoToOrganizationCommand.OfType<string>().Subscribe(name =>
            {
                var vm = CreateViewModel<OrganizationViewModel>();
                vm.Name = name;
                ShowViewModel(vm);
            });

            GoToOwnedRepositoriesCommand = new ReactiveCommand();
            GoToOwnedRepositoriesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserRepositoriesViewModel>();
                vm.Username = Account.Username;
                ShowViewModel(vm);
            });

            GoToStarredRepositoriesCommand = new ReactiveCommand();
            GoToStarredRepositoriesCommand.Subscribe(_ => CreateAndShowViewModel<RepositoriesStarredViewModel>());

            GoToPublicGistsCommand = new ReactiveCommand();
            GoToPublicGistsCommand.Subscribe(_ => CreateAndShowViewModel<PublicGistsViewModel>());

            GoToStarredGistsCommand = new ReactiveCommand();
            GoToStarredGistsCommand.Subscribe(_ => CreateAndShowViewModel<StarredGistsViewModel>());

            GoToMyGistsCommand = new ReactiveCommand();
            GoToMyGistsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserGistsViewModel>();
                vm.Username = Account.Username;
                ShowViewModel(vm);
            });

            GoToMyEvents = new ReactiveCommand();
            GoToMyEvents.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserEventsViewModel>();
                vm.Username = Account.Username;
                ShowViewModel(vm);
            });

            LoadCommand = new ReactiveCommand();
            LoadCommand.Subscribe(_ =>
            {
                var notificationRequest = applicationService.Client.Notifications.GetAll();
                notificationRequest.RequestFromCache = false;
                notificationRequest.CheckIfModified = false;

                applicationService.Client.ExecuteAsync(notificationRequest)
                    .ContinueWith(t => Notifications = t.Result.Data.Count);

                applicationService.Client.ExecuteAsync(applicationService.Client.AuthenticatedUser.GetOrganizations())
                    .ContinueWith(t => Organizations = t.Result.Data.Select(y => y.Login).ToList());
            });

        }
예제 #60
0
 public ApplicationService(IAccountsService accounts, IMvxViewDispatcher viewDispatcher)
 {
     _viewDispatcher = viewDispatcher;
     Accounts = accounts;
 }