示例#1
0
        public AccountsViewModel(ISessionService sessionService, IAccountsRepository accountsRepository)
        {
            _accountsRepository = accountsRepository;
            _sessionService = sessionService;

            Title = "Accounts";

            Accounts = _accounts.CreateDerivedCollection(CreateAccountItem);

            this.WhenAnyValue(x => x.ActiveAccount)
                .Select(x => x == null ? string.Empty : x.Key)
                .Subscribe(x =>
                {
                    foreach (var account in Accounts)
                        account.Selected = account.Id == x;
                });

            var canDismiss = this.WhenAnyValue(x => x.ActiveAccount).Select(x => x != null);
            DismissCommand = ReactiveCommand.Create(canDismiss).WithSubscription(x => Dismiss());

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

            // Activate immediately since WhenActivated triggers off Did* instead of Will* in iOS
            UpdateAccounts();
            this.WhenActivated(d => UpdateAccounts());
        }
示例#2
0
 public TransactionsService(ApplicationDbContext context, IMapper mapper, ITransactionsRepository <TransactionsModel> repo, IAccountsRepository <AccountsModel> accountsRepo, IDateTimeHelper dateTimeHelper)
 {
     _repo           = repo;
     _mapper         = mapper;
     _accountsRepo   = accountsRepo;
     _dateTimeHelper = dateTimeHelper;
 }
        public void AccountsRepository_UnitOfWork_Instantiation_Test()
        {
            IUnitOfWork         unitOfWork = new Social.Data.UnitOfWork.Implementation.UnitOfWork();
            IAccountsRepository repository = unitOfWork.AccountsRepository;

            Assert.IsNotNull(repository);
        }
示例#4
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="configuration"></param>
 /// <param name="jwtApp"></param>
 /// <param name="accountRepository"></param>
 public AuthsController(ILogger <AuthsController> logger, IConfiguration configuration, IJwtRepository jwtApp, IAccountsRepository accountRepository)
 {
     _configuration     = configuration;
     _jwtApp            = jwtApp;
     _accountRepository = accountRepository;
     _logger            = logger;
 }
        public async Task ShouldBeAbleToUpdateAccountAsync()
        {
            // Arrange
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            _service = new Service.Service.AccountsService(dbContext, _mapper);
            Account accountEntity = new Account()
            {
                Name     = "Client",
                Balance  = 2,
                IsActive = true,
                Type     = AccountType.CreditCard,
                ClientId = 1,
            };

            dbContext.Accounts.Add(accountEntity);
            dbContext.SaveChanges();

            AccountDTO accountDto = new AccountDTO()
            {
                Name     = "Client",
                Balance  = 2,
                IsActive = true,
                Type     = AccountType.CreditCard,
                ClientId = 1,
            };

            //Act
            var response = _service.PutAccount(accountEntity.Id, accountDto);

            // Assert
            Assert.AreEqual(accountDto.Name, response.Name);
        }
示例#6
0
 public PaysServiceImpl(IPaysRepository paysRepository, IUserRepository userRepository, IWalletRepository walletRepository, IAccountsRepository accountsRepository)
 {
     this.paysRepository     = paysRepository;
     this.userRepository     = userRepository;
     this.walletRepository   = walletRepository;
     this.accountsRepository = accountsRepository;
 }
示例#7
0
 public AccountsFactory(IAccountsRepository accountsRepository, IInputHelper inputHelper,
                        IConsoleHelper consoleHelper)
 {
     _accountsRepository = accountsRepository;
     _inputHelper        = inputHelper;
     _consoleHelper      = consoleHelper;
 }
示例#8
0
        public async Task ChangeUserPasswordCommand_UserPasswordAndSaltChanged()
        {
            // Arrange
            const string        userName           = "******";
            Guid                userId             = Guid.NewGuid();
            const string        userPassword       = "******";
            const string        passwordSalt       = "SaltySalt";
            User                user               = new User(userId, userName, "Dirk", "Gently", "*****@*****.**", userPassword, passwordSalt, "555-1234");
            IAccountsRepository accountsRepository = _container.Resolve <IAccountsRepository>();
            await accountsRepository.Add(user);

            // Act
            ICommandBus  commandBus  = _container.Resolve <ICommandBus>();
            const string newPassword = "******";
            await commandBus.Send(new ChangeUserPasswordCommand
            {
                UserId   = userId,
                Password = newPassword
            });

            IAccountsPerspective        accountsPerspective = _container.Resolve <IAccountsPerspective>();
            AccountWithCredentialsModel userWithCredentials = await accountsPerspective.GetUserWithCredentials(userName);

            // Assert
            userWithCredentials.PasswordHash
            .Should().NotBeNullOrWhiteSpace("Password should be hashed and contained")
            .And.NotBe(userPassword)
            .And.NotBe(newPassword);

            userWithCredentials.PasswordSalt
            .Should().NotBeEmpty()
            .And.NotBe(passwordSalt);
        }
 public JWTAuthenticationStateProvider(IJSRuntime js, HttpClient httpClient,
                                       IAccountsRepository accountsRepository)
 {
     this.js                 = js;
     this.httpClient         = httpClient;
     this.accountsRepository = accountsRepository;
 }
示例#10
0
 public AccountsService(
     IAccountsRepository accountsRepository,
     IMetersRepository metersRepository)
 {
     _AccountsRepository = accountsRepository;
     _MetersRepository   = metersRepository;
 }
示例#11
0
        public async Task ShouldBeAbleToAddAccountAsync()
        {
            // Arrange
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            _service = new Service.Service.AccountsService(dbContext, _mapper);
            AccountDTO account = new AccountDTO()
            {
                Name = "blhs",
                // Balance = 1,5 ,
                // Type = ,
                IsActive = true,
                ClientId = 1
            };

            //Act
            var response = _service.SaveAccount(account);
            var item     = dbContext.Accounts.Find(response.Id);

            // Assert
            Assert.AreEqual(item.Name, response.Name);
            Assert.AreEqual(item.Balance, response.Balance);
            Assert.AreEqual(item.Type, response.Type);
            Assert.AreEqual(item.IsActive, response.IsActive);
            Assert.AreEqual(item.ClientId, response.ClientId);
        }
 public WebhookController(
     ILogger <WebhookController> logger,
     IAccountsRepository accountsRepository)
 {
     _logger             = logger;
     _accountsRepository = accountsRepository;
 }
示例#13
0
        public OAuthFlowLoginViewModel(
            IAccountsRepository accountsRepository,
            IActionMenuFactory actionMenuService,
            IAlertDialogFactory alertDialogService)
        {
            _accountsRepository = accountsRepository;
            _alertDialogService = alertDialogService;

            Title = "Login";

            var oauthLogin = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<OAuthTokenLoginViewModel>()));

            var canLogin = this.WhenAnyValue(x => x.Code).Select(x => !string.IsNullOrEmpty(x));
            var loginCommand = ReactiveCommand.CreateAsyncTask(canLogin,_ => Login(Code));
            loginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
            LoginCommand = loginCommand;

            ShowLoginOptionsCommand = ReactiveCommand.CreateAsyncTask(sender =>
            {
                var actionMenu = actionMenuService.Create();
                actionMenu.AddButton("Login via Token", oauthLogin);
                return actionMenu.Show(sender);
            });

            _loginUrl = this.WhenAnyValue(x => x.WebDomain)
                .IsNotNull()
                .Select(x => x.TrimEnd('/'))
                .Select(x => 
                    string.Format(x + "/login/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", 
                    ClientId, Uri.EscapeDataString(RedirectUri), Uri.EscapeDataString(string.Join(",", OctokitClientFactory.Scopes))))
                .ToProperty(this, x => x.LoginUrl);

            WebDomain = DefaultWebDomain;
        }
示例#14
0
 public TransactionServices(IAccountsRepository accountsRepository, IDispositionsRepository dispositionsRepository, ITransactionsRepository transactionsRepository, AccountServices accountServices)
 {
     _accountsRepository     = accountsRepository;
     _dispositionsRepository = dispositionsRepository;
     _transactionsRepository = transactionsRepository;
     _accountServices        = accountServices;
 }
        private static byte[] arcDeclined = FormattingUtils.Formatting.HexStringToByteArray("3035"); //declined code

        public TransactionController(
            ITransactionsRepository transactionRepository,
            IAccountsRepository accountsRepository)
        {
            _transactionRepository = transactionRepository;
            _accountsRepository    = accountsRepository;
        }
示例#16
0
	public Accounts (UIWindow window, IAccountsRepository repository): base(new RootElement(""),true)
	{
		this.repository = repository;
		Style = UITableViewStyle.Plain;
		EnableSearch = true;

	}
示例#17
0
        public AccountViewModel(IEventAggregator eventAggregator, IAccountsRepository accountsRepository, PostingsViewModel postingsViewModel)
        {
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            if (accountsRepository == null)
            {
                throw new ArgumentNullException("accountsRepository");
            }

            if (postingsViewModel == null)
            {
                throw new ArgumentNullException("postingsViewModel");
            }

            EventAggregator    = eventAggregator;
            AccountsRepository = accountsRepository;
            PostingsVM         = postingsViewModel;
            PostingsVM.ConductWith(this);
            PostingsVM.Parent = this;

            //TODO: Subscription required to listen on any new/updated/deleted postings so that account could update in balance locally.
            //TODO: This should be implemented later.
            EventAggregator.Subscribe(this);
            Translator.CultureChanged += (sender, args) =>
            {
                NotifyOfPropertyChange(() => FirstPostingDate);
                NotifyOfPropertyChange(() => LastPostingDate);
            };
        }
示例#18
0
        public async Task PutAccount_ShouldWork()
        {
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            accountsRepository        = new AccountsService(dbContext, mapper);

            //Arrange
            var accountDto = new AccountDTO
            {
                Id       = 1,
                Name     = "Updated Account",
                Type     = AccountType.CreditCard,
                Balance  = 529m,
                IsActive = true,
                ClientId = 2
            };

            //Actual
            var actual = accountsRepository.PutAccount(accountDto.Id, accountDto);

            //Assert
            Assert.Equal(accountDto.Name, actual.Name);
            Assert.Equal(accountDto.Type, actual.Type);
            Assert.Equal(accountDto.Balance, actual.Balance);
            Assert.Equal(accountDto.IsActive, actual.IsActive);
            Assert.Equal(accountDto.ClientId, actual.ClientId);
        }
示例#19
0
        public async Task PutAccount_ShouldNotWork()
        {
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            accountsRepository        = new AccountsService(dbContext, mapper);

            //Arrange
            var accountDto = new AccountDTO
            {
                Id       = 62,
                Name     = "Updated Account",
                Type     = AccountType.CreditCard,
                Balance  = 529m,
                IsActive = true,
                ClientId = 2
            };

            //Actual

            //Assert
            var exception = Assert.Throws <Exception>
                                (() => accountsRepository.PutAccount(accountDto.Id, accountDto));

            Assert.Equal("Account not found", exception.Message);
        }
            public async Task ShouldBeAbleToAddAccountAsync()
            {
                // Arrange
                using var factory         = new SQLiteDbContextFactory();
                await using var dbContext = factory.CreateContext();
                _accountService           = new BankApplication.Service.Service.AccountsService(dbContext, _mapper);
                AccountDTO account = new AccountDTO()
                {
                    Name     = "Account",
                    Balance  = 000,
                    Type     = AccountType.SavingsAccount,
                    IsActive = false,
                    ClientId = 4
                };

                //Act
                var response = _accountService.SaveAccount(account);
                var item     = dbContext.Accounts.Find(response.Id);

                // Assert
                Assert.AreEqual(item.Name, response.Name);
                Assert.AreEqual(item.Balance, response.Balance);
                Assert.AreEqual(item.Type, response.Type);
                Assert.AreEqual(item.IsActive, response.IsActive);
                Assert.AreEqual(item.ClientId, response.ClientId);
            }
示例#21
0
 public AccountService(
     IAccountsRepository accountsRepository,
     IMapper mapper)
 {
     _accountsRepository = accountsRepository;
     _mapper             = mapper;
 }
示例#22
0
 public StoreRepository(ApiDbContext context, IAccountsRepository accountRepository, ITransactionsRepository transactionRepository, ICardsRepository cardsRepository)
 {
     _context               = context;
     _accountRepository     = accountRepository;
     _transactionRepository = transactionRepository;
     _cardsRepository       = cardsRepository;
 }
 public AccountSettingManager(IAccountsService accountsService,
                              IProjectsService projectsService,
                              ITemplatesService templateService,
                              ICacheManager cacheManager) : base(accountsService, projectsService, templateService, cacheManager)
 {
     _accountsRepository = new AccountsRepository();
 }
示例#24
0
        public AccountsViewModel(ISessionService sessionService, IAccountsRepository accountsRepository)
        {
            _accountsRepository = accountsRepository;
            _sessionService     = sessionService;

            Title = "Accounts";

            Items = _accounts.CreateDerivedCollection(CreateAccountItem);

            this.WhenAnyValue(x => x.ActiveAccount)
            .Select(x => x == null ? string.Empty : x.Key)
            .Subscribe(x =>
            {
                foreach (var account in Items)
                {
                    account.Selected = account.Id == x;
                }
            });

            var canDismiss = this.WhenAnyValue(x => x.ActiveAccount).Select(x => x != null);

            DismissCommand = ReactiveCommand.Create(canDismiss).WithSubscription(x => Dismiss());

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

            // Activate immediately since WhenActivated triggers off Did* instead of Will* in iOS
            UpdateAccounts();
            this.WhenActivated(d => UpdateAccounts());
        }
示例#25
0
        public OAuthTokenLoginViewModel(
            ILoginService loginFactory, 
            IAccountsRepository accountsRepository,
            IAlertDialogFactory alertDialogFactory)
        {
            Title = "Login";

            var canLogin = this.WhenAnyValue(y => y.Token, (x) => !string.IsNullOrEmpty(x));
            LoginCommand = ReactiveCommand.CreateAsyncTask(canLogin, async _ => 
            {
                try
                {
                    using (alertDialogFactory.Activate("Logging in..."))
                    {
                        var account = await loginFactory.Authenticate(ApiDomain, WebDomain, Token, false);
                        await accountsRepository.SetDefault(account);
                        return account;
                    }
                }
                catch (UnauthorizedException)
                {
                    throw new Exception("The provided token is invalid! Please try again or " +
                        "create a new token as this one might have been revoked.");
                }
            });

            LoginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
        }
 public AccountController(ILanguagesRepository languagesRepository, IAccountsRepository repository, IWardsRepository wardsRepository, ISpecialtiesRepository specialtiesRepository)
 {
     this._languagesRepository   = languagesRepository;
     this._repository            = repository;
     this._wardsRepository       = wardsRepository;
     this._specialtiesRepository = specialtiesRepository;
 }
 public NotificationsController(INotificationsRepository r, IAccountsRepository a,
                                UserManager <ApplicationUser> uManager)
 {
     notifications = r;
     accounts      = a;
     userManager   = uManager;
 }
示例#28
0
 public AuthenticationController(IAuthenticationService authenticationService, IAccountsRepository accountsRepository)
 {
     Contract.Requires(authenticationService != null);
     Contract.Requires(accountsRepository != null);
     this.authenticationService = authenticationService;
     this.accountsRepository    = accountsRepository;
 }
示例#29
0
        public OAuthTokenLoginViewModel(
            ILoginService loginFactory,
            IAccountsRepository accountsRepository,
            IAlertDialogFactory alertDialogFactory)
        {
            Title = "Login";

            var canLogin = this.WhenAnyValue(y => y.Token, (x) => !string.IsNullOrEmpty(x));

            LoginCommand = ReactiveCommand.CreateAsyncTask(canLogin, async _ =>
            {
                try
                {
                    using (alertDialogFactory.Activate("Logging in..."))
                    {
                        var account = await loginFactory.Authenticate(ApiDomain, WebDomain, Token, false);
                        await accountsRepository.SetDefault(account);
                        return(account);
                    }
                }
                catch (UnauthorizedException)
                {
                    throw new Exception("The provided token is invalid! Please try again or " +
                                        "create a new token as this one might have been revoked.");
                }
            });

            LoginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
        }
示例#30
0
        public async Task SaveAccount_ShouldWork()
        {
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            accountsRepository        = new AccountsService(dbContext, mapper);

            //Arrange
            var expectedCount = await dbContext.Accounts.CountAsync() + 1;

            var accountDto = new AccountDTO
            {
                Name     = "New Account",
                Type     = AccountType.SavingsAccount,
                Balance  = 924m,
                IsActive = true,
                ClientId = 1
            };

            //Actual
            var actual      = accountsRepository.SaveAccount(accountDto);
            var actualCount = await dbContext.Accounts.CountAsync();

            //Assert
            Assert.NotNull(actual);
            Assert.Equal(expectedCount, actualCount);
            Assert.Equal(accountDto.Name, actual.Name);
            Assert.Equal(accountDto.Type, actual.Type);
            Assert.Equal(accountDto.Balance, actual.Balance);
            Assert.Equal(accountDto.IsActive, actual.IsActive);
            Assert.Equal(accountDto.ClientId, actual.ClientId);
        }
示例#31
0
        public SettingsViewModel(ISessionService applicationService, IFeaturesService featuresService, 
            IAccountsRepository accountsService, IEnvironmentalService environmentalService, 
            IPushNotificationRegistrationService pushNotificationsService)
        {
            Title = "Account Settings";

            _sessionService = applicationService;
            _featuresService = featuresService;
            _accountsService = accountsService;
            _environmentService = environmentalService;
            _pushNotificationsService = pushNotificationsService;

            AccountImageUrl = applicationService.Account.AvatarUrl;

            GoToDefaultStartupViewCommand = ReactiveCommand.Create();
            GoToDefaultStartupViewCommand.Subscribe(_ => 
            {
                var vm = this.CreateViewModel<DefaultStartupViewModel>();
                vm.WhenAnyValue(x => x.SelectedStartupView)
                    .Subscribe(x => DefaultStartupViewName = x);
                NavigateTo(vm);
            });

            GoToSyntaxHighlighterCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm = this.CreateViewModel<SyntaxHighlighterViewModel>();
                vm.SaveCommand.Subscribe(__ => SyntaxHighlighter = vm.SelectedTheme);
                NavigateTo(vm);
            });

            DeleteAllCacheCommand = ReactiveCommand.Create();

            GoToSourceCodeCommand = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = this.CreateViewModel<RepositoryViewModel>();
                vm.Init("thedillonb", "codehub");
                NavigateTo(vm);
            });

            ShowOrganizationsInEvents = applicationService.Account.ShowOrganizationsInEvents;
            this.WhenAnyValue(x => x.ShowOrganizationsInEvents).Skip(1).Subscribe(x =>
            {
                applicationService.Account.ShowOrganizationsInEvents = x;
                accountsService.Update(applicationService.Account);
            });

            ExpandOrganizations = applicationService.Account.ExpandOrganizations;
            this.WhenAnyValue(x => x.ExpandOrganizations).Skip(1).Subscribe(x =>
            {
                applicationService.Account.ExpandOrganizations = x;
                accountsService.Update(applicationService.Account);
            });

            ShowRepositoryDescriptionInList = applicationService.Account.ShowRepositoryDescriptionInList;
            this.WhenAnyValue(x => x.ShowRepositoryDescriptionInList).Skip(1).Subscribe(x =>
            {
                applicationService.Account.ShowRepositoryDescriptionInList = x;
                accountsService.Update(applicationService.Account);
            });
        }
示例#32
0
        public SettingsViewModel(ISessionService applicationService, IFeaturesService featuresService,
                                 IAccountsRepository accountsService, IEnvironmentalService environmentalService,
                                 IPushNotificationRegistrationService pushNotificationsService)
        {
            Title = "Account Settings";

            _sessionService           = applicationService;
            _featuresService          = featuresService;
            _accountsService          = accountsService;
            _environmentService       = environmentalService;
            _pushNotificationsService = pushNotificationsService;

            AccountImageUrl = applicationService.Account.AvatarUrl;

            GoToDefaultStartupViewCommand = ReactiveCommand.Create();
            GoToDefaultStartupViewCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel <DefaultStartupViewModel>();
                vm.WhenAnyValue(x => x.SelectedStartupView)
                .Subscribe(x => DefaultStartupViewName = x);
                NavigateTo(vm);
            });

            GoToSyntaxHighlighterCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm = this.CreateViewModel <SyntaxHighlighterViewModel>();
                vm.SaveCommand.Subscribe(__ => SyntaxHighlighter = vm.SelectedTheme);
                NavigateTo(vm);
            });

            DeleteAllCacheCommand = ReactiveCommand.Create();

            GoToSourceCodeCommand = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = this.CreateViewModel <RepositoryViewModel>();
                vm.Init("thedillonb", "codehub");
                NavigateTo(vm);
            });

            ShowOrganizationsInEvents = applicationService.Account.ShowOrganizationsInEvents;
            this.WhenAnyValue(x => x.ShowOrganizationsInEvents).Skip(1).Subscribe(x =>
            {
                applicationService.Account.ShowOrganizationsInEvents = x;
                accountsService.Update(applicationService.Account);
            });

            ExpandOrganizations = applicationService.Account.ExpandOrganizations;
            this.WhenAnyValue(x => x.ExpandOrganizations).Skip(1).Subscribe(x =>
            {
                applicationService.Account.ExpandOrganizations = x;
                accountsService.Update(applicationService.Account);
            });

            ShowRepositoryDescriptionInList = applicationService.Account.ShowRepositoryDescriptionInList;
            this.WhenAnyValue(x => x.ShowRepositoryDescriptionInList).Skip(1).Subscribe(x =>
            {
                applicationService.Account.ShowRepositoryDescriptionInList = x;
                accountsService.Update(applicationService.Account);
            });
        }
 public StartupManager(ILog log, IAuditRepository auditRepository, IEodTaxFileMissingRepository taxFileMissingRepository, IComplexityWarningRepository complexityWarningRepository, IAccountsRepository accountsRepository)
 {
     _log                         = log;
     _auditRepository             = auditRepository;
     _taxFileMissingRepository    = taxFileMissingRepository;
     _complexityWarningRepository = complexityWarningRepository;
     _accountsRepository          = accountsRepository;
 }
        public AccountServiceTests(TestFixture <Startup> fixture)
        {
            Contract.Requires(fixture != null);

            accountsRepository     = (IAccountsRepository)fixture.Server.Host.Services.GetService(typeof(IAccountsRepository));
            accountsService        = (IAccountsService)fixture.Server.Host.Services.GetService(typeof(IAccountsService));
            blockedUsersRepository = (IBlockedUsersRepository)fixture.Server.Host.Services.GetService(typeof(IBlockedUsersRepository));
        }
 public static void Initialize(IAccountsCache cache)
 {
     _instance = new BrightstarAccountsRepository(
         RoleEnvironment.GetConfigurationSettingValue(AzureConstants.SuperUserAccountPropertyName),
         RoleEnvironment.GetConfigurationSettingValue(AzureConstants.SuperUserKeyPropertyName),
         cache
         );
 }
示例#36
0
 public SrvClientManager(IClientAccountsRepository tradersRepository, ISrvSmsConfirmator srvSmsConfirmator, 
     IPersonalDataRepository personalDataRepository, ISrvLykkeWallet srvLykkeWallet, IAccountsRepository accountsRepository)
 {
     _tradersRepository = tradersRepository;
     _srvSmsConfirmator = srvSmsConfirmator;
     _personalDataRepository = personalDataRepository;
     _srvLykkeWallet = srvLykkeWallet;
     _accountsRepository = accountsRepository;
 }
示例#37
0
        public StartupViewModel(
            ISessionService sessionService, 
            IAccountsRepository accountsService, 
            IAlertDialogFactory alertDialogFactory,
            IDefaultValueService defaultValueService)
        {
            _sessionService = sessionService;
            _accountsService = accountsService;
            _alertDialogFactory = alertDialogFactory;
            _defaultValueService = defaultValueService;

            StartupCommand = ReactiveCommand.CreateAsyncTask(x => Load());
        }
        public SyntaxHighlighterViewModel(ISessionService applicationService,
            IAccountsRepository accountsRepository, IFilesystemService filesystemService)
        {
            Title = "Syntax Highlighter";

            var path = System.IO.Path.Combine("WebResources", "styles");
            Themes = filesystemService.GetFiles(path)
                .Where(x => x.EndsWith(".css", StringComparison.Ordinal))
                .Select(x => System.IO.Path.GetFileNameWithoutExtension(x))
                .ToList();

            SelectedTheme = applicationService.Account.CodeEditTheme ?? "idea";

            SaveCommand = ReactiveCommand.CreateAsyncTask(async t => {
                applicationService.Account.CodeEditTheme = SelectedTheme;
                await accountsRepository.Update(applicationService.Account);
            });
        }
        public EnterpriseOAuthTokenLoginViewModel(
            ILoginService loginFactory, 
            IAccountsRepository accountsRepository,
            IAlertDialogFactory alertDialogFactory)
        {
            Title = "Login";

            LoginCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                if (string.IsNullOrEmpty(Domain))
                    throw new ArgumentException("Must have a valid GitHub domain");
                if (string.IsNullOrEmpty(Token))
                    throw new ArgumentException("Must have a valid Token");
                
                Uri domainUri;
                if (!Uri.TryCreate(Domain, UriKind.Absolute, out domainUri))
                    throw new Exception("The provided domain is not a valid URL.");

                var apiUrl = Domain;
                if (apiUrl != null)
                {
                    if (!apiUrl.EndsWith("/", StringComparison.Ordinal))
                        apiUrl += "/";
                    if (!apiUrl.Contains("/api/"))
                        apiUrl += "api/v3/";
                }

                try
                {
                    using (alertDialogFactory.Activate("Logging in..."))
                    {
                        var account = await loginFactory.Authenticate(apiUrl, Domain, Token, true);
                        await accountsRepository.SetDefault(account);
                        return account;
                    }
                }
                catch (UnauthorizedException)
                {
                    throw new Exception("The provided token is invalid! Please try again or " +
                        "create a new token as this one might have been revoked.");
                }
            });

            LoginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
        }
示例#40
0
        public DefaultStartupViewModel(ISessionService sessionService, IAccountsRepository accountsService)
        {
            Title = "Default Startup View";

            var menuViewModelType = typeof(MenuViewModel);

            SelectedStartupView = sessionService.Account.DefaultStartupView;
            this.WhenAnyValue(x => x.SelectedStartupView).Skip(1).Subscribe(x =>
            {
                sessionService.Account.DefaultStartupView = x;
                accountsService.Update(sessionService.Account);
                Dismiss();
            });

            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);
        }
        public AddEnterpriseAccountViewModel(
            ILoginService loginFactory, 
            IAccountsRepository accountsRepository,
            IAlertDialogFactory alertDialogFactory,
            IActionMenuFactory actionMenuFactory)
            : base(alertDialogFactory)
        {
            _loginFactory = loginFactory;
            _accountsRepository = accountsRepository;

            var gotoOAuthToken = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = this.CreateViewModel<EnterpriseOAuthTokenLoginViewModel>();
                vm.Domain = Domain;
                NavigateTo(vm);
            });

            ShowLoginOptionsCommand = ReactiveCommand.CreateAsyncTask(sender => {
                var actionMenu = actionMenuFactory.Create();
                actionMenu.AddButton("Login via Token", gotoOAuthToken);
                return actionMenu.Show(sender);
            });
        }
示例#42
0
        public static void Migrate(IAccountsRepository accounts)
        {
            var accountsDir = AccountPreferencesService.AccountsDir;
            if (!Directory.Exists(accountsDir))
                return;

            var accountsDb = Path.Combine(accountsDir, "accounts.db");
            if (!File.Exists(accountsDb))
                return;

            var db = new SQLiteConnection(accountsDb);
            foreach (var account in db.Table<GitHubAccount>())
            {
                // Create a new account
                accounts.Insert(new CodeHub.Core.Data.GitHubAccount
                {
                    AvatarUrl = account.AvatarUrl,
                    Username = account.Username,
                    ShowOrganizationsInEvents = account.ShowOrganizationsInEvents,
                    ShowRepositoryDescriptionInList = account.ShowRepositoryDescriptionInList,
                    IsPushNotificationsEnabled = account.IsPushNotificationsEnabled,
                    ExpandOrganizations = account.ExpandOrganizations,
                    IsEnterprise = account.IsEnterprise,
                    Domain = account.Domain,
                    WebDomain = account.WebDomain,
                    OAuth = account.OAuth,
                    PinnnedRepositories = account.PinnnedRepositories.Select(x =>
                        new CodeHub.Core.Data.PinnedRepository() {
                            Name = x.Name,
                            Owner = x.Owner,
                            Slug = x.Slug
                        }).ToList()
                });
            }

            File.Delete(accountsDb);
        }
示例#43
0
 public AssetsController(IAccountsRepository accountsRepository)
 {
     _accountsRepository = accountsRepository;
 }
示例#44
0
 public UserController(IAccountsContext context, IAccountsRepository<User> userRepository)
 {
     _context = context;
     _userRepository = userRepository;
 }
示例#45
0
        public MenuViewModel(ISessionService sessionService, IAccountsRepository accountsService)
        {
            _applicationService = sessionService;

            GoToNotificationsCommand = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = this.CreateViewModel<NotificationsViewModel>();
                vm.NotificationCount.Subscribe(x => Notifications = x);
                NavigateTo(vm);
            });

            GoToAccountsCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<AccountsViewModel>()));

            GoToProfileCommand = ReactiveCommand.Create();
            GoToProfileCommand
                .Select(_ => this.CreateViewModel<UserViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);

            GoToMyIssuesCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<MyIssuesViewModel>()));
     
            GoToRepositoryCommand = ReactiveCommand.Create();
            GoToRepositoryCommand.OfType<RepositoryIdentifier>().Subscribe(x => {
                var vm = this.CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = x.Owner;
                vm.RepositoryName = x.Name;
                NavigateTo(vm);
            });

            GoToSettingsCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<SettingsViewModel>()));

            GoToNewsCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<NewsViewModel>()));

            GoToOrganizationsCommand = ReactiveCommand.Create();
            GoToOrganizationsCommand
                .Select(_ => this.CreateViewModel<OrganizationsViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);

            GoToTrendingRepositoriesCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<RepositoriesTrendingViewModel>()));

            GoToExploreRepositoriesCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<ExploreViewModel>()));

            GoToOrganizationEventsCommand = ReactiveCommand.Create();
            GoToOrganizationEventsCommand
                .OfType<Octokit.Organization>()
                .Select(x => this.CreateViewModel<UserEventsViewModel>().Init(x.Login))
                .Subscribe(NavigateTo); 

            GoToOrganizationCommand = ReactiveCommand.Create();
            GoToOrganizationCommand
                .OfType<Octokit.Organization>()
                .Select(x => this.CreateViewModel<OrganizationViewModel>().Init(x.Login))
                .Subscribe(NavigateTo);

            GoToOwnedRepositoriesCommand = ReactiveCommand.Create();
            GoToOwnedRepositoriesCommand
                .Select(_ => this.CreateViewModel<UserRepositoriesViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);

            GoToStarredRepositoriesCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<RepositoriesStarredViewModel>()));

            GoToWatchedRepositoriesCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<RepositoriesWatchedViewModel>()));

            GoToPublicGistsCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<PublicGistsViewModel>()));

            GoToStarredGistsCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<StarredGistsViewModel>()));

            GoToMyGistsCommand = ReactiveCommand.Create();
            GoToMyGistsCommand
                .Select(_ => this.CreateViewModel<UserGistsViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);
  
            GoToMyEvents = ReactiveCommand.Create();
            GoToMyEvents
                .Select(_ => this.CreateViewModel<UserEventsViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo); 
                
            GoToFeedbackCommand = ReactiveCommand.Create();
            GoToFeedbackCommand
                .Select(x => this.CreateViewModel<WebBrowserViewModel>())
                .Select(x => x.Init("https://codehub.uservoice.com"))
                .Subscribe(NavigateTo);

            DeletePinnedRepositoryCommand = ReactiveCommand.Create();

            DeletePinnedRepositoryCommand.OfType<PinnedRepository>()
                .Subscribe(x => {
                    sessionService.Account.PinnnedRepositories.Remove(x);
                    accountsService.Update(sessionService.Account);
                });

            LoadCommand = ReactiveCommand.CreateAsyncTask(_ => {
                var notifications = sessionService.GitHubClient.Notification.GetAllForCurrent();
                notifications.ToBackground(x => Notifications = x.Count);

                var organizations = sessionService.GitHubClient.Organization.GetAllForCurrent();
                organizations.ToBackground(x => Organizations = x);

                return Task.WhenAll(notifications, organizations);
            });
        }
示例#46
0
 public ListController(IAccountsRepository accountsRepository)
 {
     _accountsRepository = accountsRepository;
 }
示例#47
0
 public SessionService(IAccountsRepository accountsRepository, IAnalyticsService analyticsService)
 {
     _accountsRepository = accountsRepository;
     _analyticsService = analyticsService;
 }
示例#48
0
 public SrvLykkeWalletMock(IMockLykkeWalletRepository mockLykkeWalletRepository, IAccountsRepository accountsRepository)
 {
     _mockLykkeWalletRepository = mockLykkeWalletRepository;
     _accountsRepository = accountsRepository;
 }
示例#49
0
 public AccountsController(IAccountsRepository repository)
 {
     AccountsRepository = repository;
 }
示例#50
0
        public MenuViewModel(ISessionService sessionService, IAccountsRepository accountsService)
        {
            _sessionService = sessionService;

            this.WhenAnyValue(x => x.Account)
                .Select(x => new GitHubAvatar(x.AvatarUrl))
                .ToProperty(this, x => x.Avatar, out _avatar);

            GoToNotificationsCommand = ReactiveCommand.Create().WithSubscription(_ => {
                var vm = this.CreateViewModel<NotificationsViewModel>();
                vm.NotificationCount.Subscribe(x => Notifications = x);
                NavigateTo(vm);
            });

            GoToAccountsCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<AccountsViewModel>()));

            GoToProfileCommand = ReactiveCommand.Create();
            GoToProfileCommand
                .Select(_ => this.CreateViewModel<UserViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);

            GoToMyIssuesCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<MyIssuesViewModel>()));
     
            GoToRepositoryCommand = ReactiveCommand.Create();
            GoToRepositoryCommand.OfType<RepositoryIdentifier>()
                .Select(x => this.CreateViewModel<RepositoryViewModel>().Init(x.Owner, x.Name))
                .Subscribe(NavigateTo);

            GoToSettingsCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<SettingsViewModel>()));

            GoToNewsCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<NewsViewModel>()));

            GoToOrganizationsCommand = ReactiveCommand.Create();
            GoToOrganizationsCommand
                .Select(_ => this.CreateViewModel<OrganizationsViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);

            GoToTrendingRepositoriesCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<RepositoriesTrendingViewModel>()));

            GoToExploreRepositoriesCommand = ReactiveCommand.Create().WithSubscription(_ =>
                NavigateTo(this.CreateViewModel<ExploreViewModel>()));

            GoToOrganizationEventsCommand = ReactiveCommand.Create();
            GoToOrganizationEventsCommand
                .OfType<Octokit.Organization>()
                .Select(x => this.CreateViewModel<UserEventsViewModel>().Init(x.Login))
                .Subscribe(NavigateTo); 

            GoToOrganizationCommand = ReactiveCommand.Create();
            GoToOrganizationCommand
                .OfType<Octokit.Organization>()
                .Select(x => this.CreateViewModel<OrganizationViewModel>().Init(x.Login))
                .Subscribe(NavigateTo);

            GoToOwnedRepositoriesCommand = ReactiveCommand.Create();
            GoToOwnedRepositoriesCommand
                .Select(_ => this.CreateViewModel<UserRepositoriesViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);

            GoToStarredRepositoriesCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<RepositoriesStarredViewModel>()));

            GoToWatchedRepositoriesCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<RepositoriesWatchedViewModel>()));

            GoToPublicGistsCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<PublicGistsViewModel>()));

            GoToStarredGistsCommand = ReactiveCommand.Create().WithSubscription(
                _ => NavigateTo(this.CreateViewModel<StarredGistsViewModel>()));

            GoToMyGistsCommand = ReactiveCommand.Create();
            GoToMyGistsCommand
                .Select(_ => this.CreateViewModel<UserGistsViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo);
  
            GoToMyEvents = ReactiveCommand.Create();
            GoToMyEvents
                .Select(_ => this.CreateViewModel<UserEventsViewModel>())
                .Select(x => x.Init(Account.Username))
                .Subscribe(NavigateTo); 
                
            GoToFeedbackCommand = ReactiveCommand.Create();
            GoToFeedbackCommand.Subscribe(_ => {
                var vm = sessionService.Account.IsEnterprise
                    ? (IBaseViewModel)this.CreateViewModel<EnterpriseSupportViewModel>()
                    : this.CreateViewModel<SupportViewModel>();
                NavigateTo(vm);
            });

            DeletePinnedRepositoryCommand = ReactiveCommand.Create();

            DeletePinnedRepositoryCommand.OfType<PinnedRepository>()
                .Subscribe(x => {
                    sessionService.Account.PinnnedRepositories.Remove(x);
                    accountsService.Update(sessionService.Account);
                });

            ActivateCommand = ReactiveCommand.Create();
            ActivateCommand.Subscribe(x => {
                var startupViewModel = sessionService.StartupViewModel;
                sessionService.StartupViewModel = null;
                if (startupViewModel != null)
                    NavigateTo(startupViewModel);
                else
                    GoToDefaultTopView.ExecuteIfCan();
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(_ => {
                var notifications = sessionService.GitHubClient.Notification.GetAllForCurrent();
                notifications.ToBackground(x => Notifications = x.Count);

                var organizations = sessionService.GitHubClient.Organization.GetAllForCurrent();
                organizations.ToBackground(x => Organizations = x);

                return Task.WhenAll(notifications, organizations);
            });
        }
示例#51
0
        public RepositoryViewModel(ISessionService applicationService, 
            IAccountsRepository accountsService, IActionMenuFactory actionMenuService)
        {
            ApplicationService = applicationService;
            _accountsService = accountsService;

            var validRepositoryObservable = this.WhenAnyValue(x => x.Repository).Select(x => x != null);

            this.WhenAnyValue(x => x.RepositoryName).Subscribe(x => Title = x);

            this.WhenAnyValue(x => x.Repository).Subscribe(x => 
            {
                Stargazers = x != null ? (int?)x.StargazersCount : null;
                Watchers = x != null ? (int?)x.SubscribersCount : null;
            });

            this.WhenAnyValue(x => x.Repository.Description)
                .Select(x => Emojis.FindAndReplace(x))
                .ToProperty(this, x => x.Description, out _description);

            ToggleStarCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.IsStarred).Select(x => x.HasValue), t => ToggleStar());

            ToggleWatchCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.IsWatched, x => x.HasValue), t => ToggleWatch());

            GoToOwnerCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Repository).Select(x => x != null));
            GoToOwnerCommand.Select(_ => Repository.Owner).Subscribe(x => {
                if (string.Equals(x.Type, "organization", StringComparison.OrdinalIgnoreCase))
                {
                    var vm = this.CreateViewModel<OrganizationViewModel>();
                    vm.Init(RepositoryOwner);
                    NavigateTo(vm);
                }
                else
                {
                    var vm = this.CreateViewModel<UserViewModel>();
                    vm.Init(RepositoryOwner);
                    NavigateTo(vm);
                }
            });

            PinCommand = ReactiveCommand.Create(validRepositoryObservable);
            PinCommand.Subscribe(x => PinRepository());

            GoToForkParentCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Repository, x => x != null && x.Fork && x.Parent != null));
            GoToForkParentCommand.Subscribe(x =>
            {
                var vm = this.CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = Repository.Parent.Owner.Login;
                vm.RepositoryName = Repository.Parent.Name;
                vm.Repository = Repository.Parent;
                NavigateTo(vm);
            });

            GoToStargazersCommand = ReactiveCommand.Create();
            GoToStargazersCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel<RepositoryStargazersViewModel>();
                vm.Init(RepositoryOwner, RepositoryName);
                NavigateTo(vm);
            });

            GoToWatchersCommand = ReactiveCommand.Create();
            GoToWatchersCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel<RepositoryWatchersViewModel>();
                vm.Init(RepositoryOwner, RepositoryName);
                NavigateTo(vm);
            });

            GoToEventsCommand = ReactiveCommand.Create();
            GoToEventsCommand.Subscribe(_ => {
                var vm = this.CreateViewModel<RepositoryEventsViewModel>();
                vm.Init(RepositoryOwner, RepositoryName);
                NavigateTo(vm);
            });

            GoToIssuesCommand = ReactiveCommand.Create();
            GoToIssuesCommand
                .Select(_ => this.CreateViewModel<IssuesViewModel>())
                .Select(x => x.Init(RepositoryOwner, RepositoryName))
                .Subscribe(NavigateTo);

            GoToReadmeCommand = ReactiveCommand.Create();
            GoToReadmeCommand
                .Select(_ => this.CreateViewModel<ReadmeViewModel>())
                .Select(x => x.Init(RepositoryOwner, RepositoryName))
                .Subscribe(NavigateTo);

            GoToBranchesCommand = ReactiveCommand.Create();
            GoToBranchesCommand
                .Select(_ => this.CreateViewModel<CommitBranchesViewModel>())
                .Select(x => x.Init(RepositoryOwner, RepositoryName))
                .Subscribe(NavigateTo);

            GoToCommitsCommand = ReactiveCommand.Create();
            GoToCommitsCommand.Subscribe(_ =>
            {
                if (Branches != null && Branches.Count == 1)
                {
                    var vm = this.CreateViewModel<CommitsViewModel>();
                    var branch = Repository == null ? null : Repository.DefaultBranch;
                    NavigateTo(vm.Init(RepositoryOwner, RepositoryName, branch));
                }
                else
                {
                    GoToBranchesCommand.ExecuteIfCan();
                }
            });

            GoToPullRequestsCommand = ReactiveCommand.Create();
            GoToPullRequestsCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel<PullRequestsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                NavigateTo(vm);
            });

            GoToSourceCommand = ReactiveCommand.Create();
            GoToSourceCommand.Subscribe(_ =>
            {
                var vm = this.CreateViewModel<BranchesAndTagsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                NavigateTo(vm);
            });

            GoToContributors = ReactiveCommand.Create();
            GoToContributors.Subscribe(_ =>
            {
                var vm = this.CreateViewModel<RepositoryContributorsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                NavigateTo(vm);
            });

            GoToForksCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm = this.CreateViewModel<RepositoryForksViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                NavigateTo(vm);
            });

            GoToReleasesCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm = this.CreateViewModel<ReleasesViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                NavigateTo(vm);
            });

            ShareCommand = ReactiveCommand.Create(validRepositoryObservable);
            ShareCommand.Subscribe(sender => actionMenuService.ShareUrl(sender, Repository.HtmlUrl));

            var canShowMenu = this.WhenAnyValue(x => x.Repository, x => x.IsStarred, x => x.IsWatched)
                .Select(x => x.Item1 != null && x.Item2 != null && x.Item3 != null);

            ShowMenuCommand = ReactiveCommand.CreateAsyncTask(canShowMenu, sender => {
                var menu = actionMenuService.Create();
                menu.AddButton(IsPinned ? "Unpin from Slideout Menu" : "Pin to Slideout Menu", PinCommand);
                menu.AddButton(IsStarred.Value ? "Unstar This Repo" : "Star This Repo", ToggleStarCommand);
                menu.AddButton(IsWatched.Value ? "Unwatch This Repo" : "Watch This Repo", ToggleWatchCommand);
                menu.AddButton("Show in GitHub", GoToHtmlUrlCommand);
                menu.AddButton("Share", ShareCommand);
                return menu.Show(sender);
            });

            var gotoWebUrl = new Action<string>(x =>
            {
                var vm = this.CreateViewModel<WebBrowserViewModel>();
                vm.Init(x);
                NavigateTo(vm);
            });

            GoToHtmlUrlCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Repository, x => x != null && !string.IsNullOrEmpty(x.HtmlUrl)));
            GoToHtmlUrlCommand.Select(_ => Repository.HtmlUrl).Subscribe(gotoWebUrl);

            GoToHomepageCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Repository, x => x != null && !string.IsNullOrEmpty(x.Homepage)));
            GoToHomepageCommand.Select(_ => Repository.Homepage).Subscribe(gotoWebUrl);

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {

                var t1 = applicationService.Client.ExecuteAsync(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Get());

                applicationService.Client.ExecuteAsync(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetReadme())
                    .ToBackground(x => Readme = x.Data);

                applicationService.Client.ExecuteAsync(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetBranches())
                    .ToBackground(x => Branches = x.Data);

                applicationService.GitHubClient.Activity.Watching.CheckWatched(RepositoryOwner, RepositoryName)
                    .ToBackground(x => IsWatched = x);

                applicationService.GitHubClient.Activity.Starring.CheckStarred(RepositoryOwner, RepositoryName)
                    .ToBackground(x => IsStarred = x);

                applicationService.Client.ExecuteAsync(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetContributors())
                    .ToBackground(x => Contributors = x.Data.Count);

//                applicationService.GitHubClient.Repository.GetAllLanguages(RepositoryOwner, RepositoryName)
//                    .ToBackground(x => Languages = x.Count);

                applicationService.Client.ExecuteAsync(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetReleases())
                    .ToBackground(x => Releases = x.Data.Count);

                Repository = (await t1).Data;
            });
        }
示例#52
0
 public LoginService(IAccountsRepository accounts)
 {
     _accounts = accounts;
 }
示例#53
0
 public FundController(IAccountsRepository accountsRepository, ISrvLykkeWallet srvLykkeWallet)
 {
     _accountsRepository = accountsRepository;
     _srvLykkeWallet = srvLykkeWallet;
 }
示例#54
0
 public AccountantService(IAccountsRepository accountsRepository, ITransactionsRepository transactionsRepository)
 {
     this._transactionsRepository = transactionsRepository;
     this._accountsRepository = accountsRepository;
 }
 public AccountController(IAccountsContext context, IAccountsRepository<User> accountsRepository)
 {
     _context = context;
     _accountsRepository = accountsRepository;
 }
示例#56
0
		public Login (UIWindow window, IAccountsRepository repository)
		{
			this.repository = repository;
			_window = window;
		}