示例#1
0
        protected BaseEventsViewModel(IApplicationService applicationService)
        {
            ApplicationService = applicationService;
            Events = new ReactiveCollection<Tuple<EventModel, EventBlock>>();
            ReportRepository = true;

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

            GoToGistCommand = new ReactiveCommand();
            GoToGistCommand.OfType<EventModel.GistEvent>().Subscribe(x =>
            {
                var vm = CreateViewModel<GistViewModel>();
                vm.Id = x.Gist.Id;
                vm.Gist = x.Gist;
                ShowViewModel(vm);
            });

            LoadCommand.RegisterAsyncTask(t => 
                this.RequestModel(CreateRequest(0, 100), t as bool?, response =>
                {
                    this.CreateMore(response, m => Events.MoreTask = m, d => Events.AddRange(CreateDataFromLoad(d)));
                    Events.Reset(CreateDataFromLoad(response.Data));
                }));
        }
 public OrganizationRepositoriesViewModel(IApplicationService applicationService)
     : base(applicationService)
 {
     ShowRepositoryOwner = false;
     LoadCommand.RegisterAsyncTask(t => 
         Repositories.SimpleCollectionLoad(applicationService.Client.Organizations[Name].Repositories.GetAll(), t as bool?));
 }
 public SegmentService(IIdentityLogicFactory identityLogicFactory, ITraitBuilder traitBuilder, IApplicationService applicationService, ILandlordService landlordService)
 {
     _identityLogicFactory = identityLogicFactory;
     _traitBuilder = traitBuilder;
     _applicationService = applicationService;
     _landlordService = landlordService;
 }
        public PullRequestsViewModel(IApplicationService applicationService)
		{
            PullRequests = new ReactiveList<PullRequestModel>();

            GoToPullRequestCommand = ReactiveCommand.Create();
		    GoToPullRequestCommand.OfType<PullRequestModel>().Subscribe(pullRequest =>
		    {
		        var vm = CreateViewModel<PullRequestViewModel>();
		        vm.RepositoryOwner = RepositoryOwner;
		        vm.RepositoryName = RepositoryName;
		        vm.PullRequestId = pullRequest.Number;
		        vm.PullRequest = pullRequest;
		        vm.WhenAnyValue(x => x.PullRequest).Skip(1).Subscribe(x =>
		        {
                    var index = PullRequests.IndexOf(pullRequest);
                    if (index < 0) return;
                    PullRequests[index] = x;
                    PullRequests.Reset();
		        });
                ShowViewModel(vm);
		    });

		    this.WhenAnyValue(x => x.SelectedFilter).Skip(1).Subscribe(_ => LoadCommand.ExecuteIfCan());

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var state = SelectedFilter == 0 ? "open" : "closed";
			    var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests.GetAll(state: state);
                return PullRequests.SimpleCollectionLoad(request, t as bool?);
            });
		}
示例#5
0
        public void TestFixtureSetUp()
        {
            try
            {
                CodeSharp.Core.Configuration.ConfigWithEmbeddedXml(null
                    , "application_config"
                    , Assembly.GetExecutingAssembly()
                    , "Properties.Model.Test.ConfigFiles")
                    .RenderProperties()
                    .Castle(o => this.Resolve(o.Container));

                Lock.InitAll(DependencyResolver.Resolve<ILockHelper>());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            this._log = DependencyResolver.Resolve<ILoggerFactory>().Create(this.GetType());
            this._sessionManager = DependencyResolver.Resolve<Castle.Facilities.NHibernateIntegration.ISessionManager>();
            this._accountService = DependencyResolver.Resolve<IAccountService>();
            this._appService = DependencyResolver.Resolve<IApplicationService>();
            this._configService = DependencyResolver.Resolve<IConfigurationService>();
            DependencyResolver.Resolve<ILockHelper>().Require<Account>();
        }
        public IssueAssignedToViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;
            Users = new ReactiveCollection<BasicUserModel>();

            SelectUserCommand = new ReactiveCommand();
            SelectUserCommand.RegisterAsyncTask(async t =>
            {
                var selectedUser = t as BasicUserModel;
                if (selectedUser != null)
                    SelectedUser = selectedUser;

                if (SaveOnSelect)
                {
                    var assignee = SelectedUser != null ? SelectedUser.Login : null;
                    var updateReq = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateAssignee(assignee);
                    await _applicationService.Client.ExecuteAsync(updateReq);
                }

                DismissCommand.ExecuteIfCan();
            });

            LoadCommand.RegisterAsyncTask(t => 
                Users.SimpleCollectionLoad(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetAssignees(), t as bool?));
        }
 public ProjectController(
     IApplicationService service, 
     IReadModelFacade facade)
 {
     _service = service;
     _facade = facade;
 }
 public virtual void SetUp()
 {
     ContentAreaRepository = MockRepository.GenerateMock<IContentAreaRepository>();
     CollectionService = MockRepository.GenerateMock<ICollectionService>();
     ApplicationService = MockRepository.GenerateMock<IApplicationService>();
     ContentAreaService = new ContentAreaService(ContentAreaRepository, CollectionService);
 }
示例#9
0
        public SourceTreeViewModel(IApplicationService applicationService, IFeaturesService featuresService)
        {
            _applicationService = applicationService;
            _featuresService = featuresService;

            GoToItemCommand = ReactiveUI.ReactiveCommand.Create();
            GoToItemCommand.OfType<ContentModel>().Subscribe(x => {
                if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
                {
                    ShowViewModel<SourceTreeViewModel>(new NavObject { Username = Username, Branch = Branch,
                        Repository = Repository, Path = x.Path, TrueBranch = TrueBranch });
                }
                if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
                {
                    if (x.DownloadUrl == null)
                    {
                        var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", StringComparison.Ordinal) + 7);
                        var indexOfGit = nameAndSlug.LastIndexOf("/git", StringComparison.Ordinal);
                        indexOfGit = indexOfGit < 0 ? 0 : indexOfGit;
                        var repoId = RepositoryIdentifier.FromFullName(nameAndSlug.Substring(0, indexOfGit));
                        if (repoId == null)
                            return;

                        var sha = x.GitUrl.Substring(x.GitUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
                        ShowViewModel<SourceTreeViewModel>(new NavObject {Username = repoId?.Owner, Repository = repoId?.Name, Branch = sha});
                    }
                    else
                    {
                        ShowViewModel<SourceViewModel>(new SourceViewModel.NavObject {
                            Name = x.Name, Username = Username, Repository = Repository, Branch = Branch,
                            Path = x.Path, HtmlUrl = x.HtmlUrl, GitUrl = x.GitUrl, TrueBranch = TrueBranch });
                    }
                }
            });
        }
示例#10
0
	    public EditSourceViewModel(IApplicationService applicationService)
	    {
            SaveCommand = new ReactiveCommand();
	        SaveCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<CommitMessageViewModel>();
	            vm.SaveCommand.RegisterAsyncTask(async t =>
	            {
                    var request = applicationService.Client.Users[Username].Repositories[Repository]
                        .UpdateContentFile(Path, vm.Message, Text, BlobSha, Branch);
                    var response = await applicationService.Client.ExecuteAsync(request);
	                Content = response.Data;
                    DismissCommand.ExecuteIfCan();
	            });
                ShowViewModel(vm);
	        });

	        LoadCommand.RegisterAsyncTask(async t =>
	        {
	            var path = Path;
                if (!path.StartsWith("/", StringComparison.Ordinal))
                    path = "/" + path;

	            var request = applicationService.Client.Users[Username].Repositories[Repository].GetContentFile(path, Branch ?? "master");
			    request.UseCache = false;
			    var data = await applicationService.Client.ExecuteAsync(request);
			    BlobSha = data.Data.Sha;
			    Text = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(data.Data.Content));
	        });
	    }
 public ApplicationServiceTest()
 {
     IApiService apiService = new ApiService();
     IUrlBuilder urlBuilder = new UrlBuilder();
     ITwitterRepository repository = new TwitterRepository();
     this._service = new ApplicationService(repository, apiService, urlBuilder);
 }
示例#12
0
        public ChangesetViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            Comments = new ReactiveList<CommentModel>();

            GoToHtmlUrlCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Commit).Select(x => x != null));
            GoToHtmlUrlCommand.Select(x => Commit).Subscribe(GoToUrlCommand.ExecuteIfCan);

            GoToRepositoryCommand = ReactiveCommand.Create();
            GoToRepositoryCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToFileCommand = ReactiveCommand.Create();
            GoToFileCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
            {
                if (x.Patch == null)
                {
                    var vm = CreateViewModel<SourceViewModel>();
                    vm.Branch = Commit.Sha;
                    vm.Username = RepositoryOwner;
                    vm.Repository = RepositoryName;
                    vm.Items = new [] 
                    { 
                        new SourceViewModel.SourceItemModel 
                        {
                            ForceBinary = true,
                            GitUrl = x.BlobUrl,
                            Name = x.Filename,
                            Path = x.Filename,
                            HtmlUrl = x.BlobUrl
                        }
                    };
                    vm.CurrentItemIndex = 0;
                    ShowViewModel(vm);
                }
                else
                {
                    var vm = CreateViewModel<ChangesetDiffViewModel>();
                    vm.Username = RepositoryOwner;
                    vm.Repository = RepositoryName;
                    vm.Branch = Commit.Sha;
                    vm.Filename = x.Filename;
                    ShowViewModel(vm);
                }
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var forceCacheInvalidation = t as bool?;
                var t1 = this.RequestModel(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Get(), forceCacheInvalidation, response => Commit = response.Data);
                Comments.SimpleCollectionLoad(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Comments.GetAll(), forceCacheInvalidation).FireAndForget();
                return t1;
            });
        }
示例#13
0
        public ApplicationModule(IApplicationService applicationService, IErrorService error)
            : base("/application")
        {
            Post["/register"] = _ =>
            {
                if (Params.AreMissing("SingleUseToken", "Name")) return error.MissingParameters(Response);
                if (!Params.SingleUseToken.IsGuid()) return error.InvalidParameters(Response);
                if (!applicationService.AuthoriseSingleUseToken(Params.SingleUseToken)) return error.PermissionDenied(Response);

                var application = applicationService.Register(Params.Name);
                return (application == null) ? error.InvalidParameters(Response) : Response.AsJson(new { ApplicationId = application.Id });

            };

            Post["/transfer"] = _ =>
            {
                if (Params.AreMissing("SingleUseToken", "Name", "Id")) return error.MissingParameters(Response);
                if (!Params.Id.IsGuid() || !Params.SingleUseToken.IsGuid()) return error.InvalidParameters(Response);
                if (!applicationService.AuthoriseSingleUseToken(Params.SingleUseToken)) return error.PermissionDenied(Response);

                var application = applicationService.Transfer(Params.Name, Params.Id);
                return (application == null) ? error.InvalidParameters(Response) : Response.AsJson(new { ApplicationId = application.Id });

            };
        }
 public GoogleAnalyticsService()
 {
     _googleAnalytics = new GoogleAnalytics();
     _googleAnalytics.CustomVariables.Add(new PropertyValue
                                              {
                                                  PropertyName = "Device ID",
                                                  Value = AnalyticsProperties.DeviceId
                                              });
     _googleAnalytics.CustomVariables.Add(new PropertyValue
                                              {
                                                  PropertyName = "Application Version",
                                                  Value = AnalyticsProperties.ApplicationVersion
                                              });
     _googleAnalytics.CustomVariables.Add(new PropertyValue
                                              {
                                                  PropertyName = "Device OS",
                                                  Value = AnalyticsProperties.OsVersion
                                              });
     _googleAnalytics.CustomVariables.Add(new PropertyValue
                                              {
                                                  PropertyName = "Device",
                                                  Value = AnalyticsProperties.Device
                                              });
     _googleAnalytics.CustomVariables.Add(new PropertyValue
                                              {
                                                  PropertyName = "Anonymous User ID",
                                                  Value = ViewModel.ViewModelLocator.ApplicationSettingsStatic.AnonymousUserId
                                              });
     _innerService = new WebAnalyticsService
                         {
                             IsPageTrackingEnabled = false,
                             Services = {_googleAnalytics,}
                         };
 }
        public CampaignLogicFactory(
            ISubscriberTrackingService<ApplicationSummary> applicationSubscriberTrackingService,
            IDataGatherFactory<ApplicationSummary> applicationGatherFactory,
            IDataGatherFactory<LandlordSummary> landlordGatherFactory,
            ISubscriberTrackingService<LandlordSummary> landlordSubscriberTrackingService,
            IApplicationService applicationService,
            ILetMeServiceUrlSettings letMeServiceUrlSettings,
            ISubscriberRecordService subscriberRecordService,
            ILogger logger
            )
        {
            Check.If(landlordSubscriberTrackingService).IsNotNull();
            Check.If(applicationService).IsNotNull();
            Check.If(applicationGatherFactory).IsNotNull();
            Check.If(letMeServiceUrlSettings).IsNotNull();
            Check.If(landlordSubscriberTrackingService).IsNotNull();

            _campaignLogic = new List<ICampaignLogic>
            {
                new AddApplicationNoGuarantorEventLogic(applicationGatherFactory, applicationSubscriberTrackingService, logger),
                new NewPropertyAddedEventLogic(applicationGatherFactory, applicationSubscriberTrackingService, letMeServiceUrlSettings, subscriberRecordService, logger),
                new BookAViewingCampaignLogic(applicationGatherFactory, applicationSubscriberTrackingService),
                new DeclinedGuarantorCampaignLogic(applicationGatherFactory, applicationSubscriberTrackingService),
                new NewPropertySubmissionCampaignLogic(landlordGatherFactory,landlordSubscriberTrackingService)
            };
        }
        protected BaseRepositoriesViewModel(IApplicationService applicationService, string filterKey = "RepositoryController")
        {
            ApplicationService = applicationService;
            ShowRepositoryOwner = true;

            var gotoRepository = new Action<RepositoryItemViewModel>(x =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = x.Owner;
                vm.RepositoryName = x.Name;
                ShowViewModel(vm);
            });

            Repositories = RepositoryCollection.CreateDerivedCollection(
                x => new RepositoryItemViewModel(x.Name, x.Owner.Login, x.Owner.AvatarUrl, 
                    ShowRepositoryDescription ? x.Description : string.Empty, x.StargazersCount, x.ForksCount, 
                    ShowRepositoryOwner, gotoRepository), 
                x => x.Name.ContainsKeyword(SearchKeyword),
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            //Filter = applicationService.Account.Filters.GetFilter<RepositoriesFilterModel>(filterKey);

            this.WhenAnyValue(x => x.Filter).Skip(1).Subscribe(_ => LoadCommand.ExecuteIfCan());

//			_repositories.FilteringFunction = x => Repositories.Filter.Ascending ? x.OrderBy(y => y.Name) : x.OrderByDescending(y => y.Name);
//            _repositories.GroupingFunction = CreateGroupedItems;
        }
示例#17
0
	    public IssueEditViewModel(IApplicationService applicationService)
	    {
	        _applicationService = applicationService;

            GoToDescriptionCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Issue, x => x != null));
	        GoToDescriptionCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<ComposerViewModel>();
	            vm.Text = Issue.Body;
	            vm.SaveCommand.Subscribe(__ =>
	            {
	                Issue.Body = vm.Text;
                    vm.DismissCommand.ExecuteIfCan();
	            });
	            ShowViewModel(vm);
	        });

	        this.WhenAnyValue(x => x.Issue).Where(x => x != null).Subscribe(x =>
	        {
                Title = x.Title;
                AssignedTo = x.Assignee;
                Milestone = x.Milestone;
                Labels = x.Labels.ToArray();
                Content = x.Body;
                IsOpen = string.Equals(x.State, "open");
	        });
	    }
示例#18
0
        public PullRequestFilesViewModel(IApplicationService applicationService)
        {
            Files = new ReactiveCollection<CommitModel.CommitFileModel>
            {
                GroupFunc = y =>
                {
                    var filename = "/" + y.Filename;
                    return filename.Substring(0, filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
                }
            };

            GoToSourceCommand =  new ReactiveCommand();
            GoToSourceCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
            {
                var vm = CreateViewModel<SourceViewModel>();
//                vm.Name = x.Filename.Substring(x.Filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
//                vm.Path = x.Filename;
//                vm.GitUrl = x.ContentsUrl;
//                vm.ForceBinary = x.Patch == null;
                ShowViewModel(vm);
            });

            LoadCommand.RegisterAsyncTask(t =>
                Files.SimpleCollectionLoad(
                    applicationService.Client.Users[Username].Repositories[Repository].PullRequests[PullRequestId]
                        .GetFiles(), t as bool?));
        }
示例#19
0
        public IssueMilestonesViewModel(IApplicationService applicationService)
        {
            Milestones = new ReactiveCollection<MilestoneModel>();

            SelectMilestoneCommand = new ReactiveCommand();
            SelectMilestoneCommand.RegisterAsyncTask(async t =>
            {
                var milestone = t as MilestoneModel;
                if (milestone != null)
                    SelectedMilestone = milestone;

                if (SaveOnSelect)
                {
                    try
                    {
                        int? milestoneNumber = null;
                        if (SelectedMilestone != null) milestoneNumber = SelectedMilestone.Number;
                        var updateReq = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateMilestone(milestoneNumber);
                        await applicationService.Client.ExecuteAsync(updateReq);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Unable to to save milestone! Please try again.", e);
                    }
                }

                DismissCommand.ExecuteIfCan();
            });

            LoadCommand.RegisterAsyncTask(t =>
                Milestones.SimpleCollectionLoad(
                    applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Milestones.GetAll(),
                    t as bool?));
        }
示例#20
0
	    public EditSourceViewModel(IApplicationService applicationService)
	    {
            SaveCommand = ReactiveCommand.Create();
	        SaveCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<CommitMessageViewModel>();
                vm.Username = Username;
                vm.Repository = Repository;
                vm.Path = Path;
                vm.Text = Text;
                vm.BlobSha = BlobSha;
                vm.Branch = Branch;
                vm.ContentChanged.Subscribe(x => Content = x);
                ShowViewModel(vm);
	        });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
	        {
	            var path = Path;
                if (!path.StartsWith("/", StringComparison.Ordinal))
                    path = "/" + path;

	            var request = applicationService.Client.Users[Username].Repositories[Repository].GetContentFile(path, Branch ?? "master");
			    request.UseCache = false;
			    var data = await applicationService.Client.ExecuteAsync(request);
			    BlobSha = data.Data.Sha;
	            var content = Convert.FromBase64String(data.Data.Content);
                Text = System.Text.Encoding.UTF8.GetString(content, 0, content.Length);
	        });
	    }
示例#21
0
        public CashHomeViewModel(ScreenCoordinator screenCoordinator, IApplicationService applicationService)
        {
            ScreenCoordinator = screenCoordinator;
            ApplicationService = applicationService;

            Text = new BindableCollection<string>();
        }
示例#22
0
        public ShellForm(IKernel kernel)
        {
            Asserter.AssertIsNotNull(kernel, "kernel");

            _kernel = kernel;
            _applicationService = _kernel.Get<IApplicationService>();
            _storageService = _kernel.Get<IStorageService>();
            _settingsService = _kernel.Get<ISettingsService>();
            _siteService = _kernel.Get<ISiteService>();
            _controller = _kernel.Get<ShellController>();

            Asserter.AssertIsNotNull(_applicationService, "_applicationService");
            Asserter.AssertIsNotNull(_storageService, "_storageService");
            Asserter.AssertIsNotNull(_settingsService, "_settingsService");
            Asserter.AssertIsNotNull(_siteService, "_siteService");

            InitializeComponent();

            _siteService.Register(SiteNames.ContentSite, contentPanel);
            _siteService.Register(SiteNames.NavigationSite, navigationPanel);
            _siteService.Register(SiteNames.ContentActionsSite, contentActionPanel);

            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.ResizeRedraw, true);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AboutViewModel" /> class.
 /// </summary>
 /// <param name="settingsService">The settings service.</param>
 /// <param name="applicationService">The application service.</param>
 public AboutViewModel(
     ISettingsService settingsService,
     IApplicationService applicationService)
 {
     this.settingsService = settingsService;
     this.applicationService = applicationService;
 }
        public AddInterestViewModel(IApplicationService applicationService)
        {
            DoneCommand = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                if (SelectedLanguage == null)
                    throw new Exception("You must select a language for your interest!");
                if (string.IsNullOrEmpty(Keyword))
                    throw new Exception("Please specify a keyword to go with your interest!");

                applicationService.Account.Interests.Insert(new Interest
                {
                    Language = _selectedLanguage.Name,
                    LanguageId = _selectedLanguage.Slug,
                    Keyword = _keyword
                });

                await DismissCommand.ExecuteAsync();
            });

            GoToLanguagesCommand = ReactiveCommand.Create();
            GoToLanguagesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<LanguagesViewModel>();
                vm.SelectedLanguage = SelectedLanguage;
                vm.WhenAnyValue(x => x.SelectedLanguage).Skip(1).Subscribe(x =>
                {
                    SelectedLanguage = x;
                    vm.DismissCommand.ExecuteIfCan();
                });
                ShowViewModel(vm);
            });

            var str = System.IO.File.ReadAllText(PopularInterestsPath, System.Text.Encoding.UTF8);
            PopularInterests = new ReactiveList<PopularInterest>(JsonConvert.DeserializeObject<List<PopularInterest>>(str));
        }
        public AthleteViewModel(IApplicationService service)
        {
            athleteInfo = new AthleteDto() { EventParticipationk__BackingField = new List<EventAreaDto>(Constants.EVENT_AREAS) };

            this._service = service;
            this.myAthletes = new ObservableCollection<AthleteDto>();
            this.showCurrent = true;
            this.showFuture = true;
            this.showPast = false;
            this.showAllInventoryItems = false;
            this.showOnlyDefaultInventoryItems = true;
            this.totalsByStatusModel = new TotalByStatusModel();

            this.SaveAthleteCommand = new RelayCommand(SaveAthlete);
            this.ClearFieldsCommand = new RelayCommand(ClearAthleteInfo);
            this.EditSelectedAthleteCommand = new RelayCommand<AthleteDto>(athleteToEdit => LoadAthleteInfoWithSelectedAthlete(athleteToEdit));

            Genders = new ObservableCollection<Char>(Data.Constants.GENDERS);
            Statuses = new ObservableCollection<String>(Data.Constants.ATHLETE_STATUSES);

            Messenger.Default.Register<ObservableCollection<AthleteDto>>(
                this,
                (a) => MyAthletes = a
            );
        }
        public GistViewableFileViewModel(IApplicationService applicationService, IFilesystemService filesystemService)
        {
            GoToFileSourceCommand = ReactiveCommand.Create();

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                string data;
                using (var ms = new System.IO.MemoryStream())
                {
                    await applicationService.Client.DownloadRawResource(GistFile.RawUrl, ms);
                    ms.Position = 0;
                    var sr = new System.IO.StreamReader(ms);
                    data = sr.ReadToEnd();
                }
                if (GistFile.Language.Equals("Markdown"))
                    data = await applicationService.Client.Markdown.GetMarkdown(data);

                string path;
                using (var stream = filesystemService.CreateTempFile(out path, "gist.html"))
                {
                    using (var fs = new System.IO.StreamWriter(stream))
                    {
                        fs.Write(data);
                    }
                }

                FilePath = path;
            });
        }
示例#27
0
        protected BaseEventsViewModel(IApplicationService applicationService)
        {
            ApplicationService = applicationService;
            var events = new ReactiveList<EventModel>();
            Events = events.CreateDerivedCollection(CreateEventTextBlocks);
            ReportRepository = true;

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

            GoToGistCommand = ReactiveCommand.Create();
            GoToGistCommand.OfType<EventModel.GistEvent>().Subscribe(x =>
            {
                var vm = CreateViewModel<GistViewModel>();
                vm.Id = x.Gist.Id;
                vm.Gist = x.Gist;
                ShowViewModel(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t => 
                this.RequestModel(CreateRequest(0, 100), t as bool?, response =>
                {
                    //this.CreateMore(response, m => { }, events.AddRange);
                    events.Reset(response.Data);
                }));
        }
        public RepositoriesStarredViewModel(IApplicationService applicationService) : base(applicationService)
        {
            ShowRepositoryOwner = true;

            LoadCommand.RegisterAsyncTask(t =>
                Repositories.SimpleCollectionLoad(
                    applicationService.Client.AuthenticatedUser.Repositories.GetStarred(), t as bool?));
        }
示例#29
0
 public ApplicationController(IApplicationService applicationService,
                              ICredentialProvider credentialProvider,
                              KuduEnvironment environment)
 {
     _applicationService = applicationService;
     _credentialProvider = credentialProvider;
     _environment = environment;
 }
        public ApplicationQueryController(IApplicationService applicationService, IApplicationQueryService queryService)
        {
            Check.If(applicationService).IsNotNull();
            Check.If(queryService).IsNotNull();

            _applicationService = applicationService;
            _queryService = queryService;
        }
示例#31
0
 public EngageApplication(IApplicationService applicationService)
 {
     _applicationService = applicationService;
 }
示例#32
0
 public MainForm(IApplicationService appService)
 {
     InitializeComponent();
     _appService = appService;
 }
示例#33
0
 public SeatsListerVm(ISeatQueries seatQueries, IApplicationService applicationService) : base(applicationService)
 {
     _seatQueries = seatQueries ?? throw new ArgumentNullException(nameof(seatQueries));
 }
        /// <summary>
        /// Invokes the middleware.
        /// </summary>
        /// <param name="context">The current http context</param>
        /// <param name="api">The current api</param>
        /// <param name="service">The application service</param>
        /// <returns>An async task</returns>
        public override async Task Invoke(HttpContext context, IApi api, IApplicationService service)
        {
            var appConfig = new Config(api);

            if (!IsHandled(context) && !context.Request.Path.Value.StartsWith("/manager/assets/"))
            {
                var url      = context.Request.Path.HasValue ? context.Request.Path.Value : "";
                var segments = url.Substring(1).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                int pos      = 0;

                //
                // 1: Store raw url
                //
                service.Url = context.Request.Path.Value;

                //
                // 2: Get the current site
                //
                Site site = null;

                var hostname = context.Request.Host.Host;

                if (_config.UseSiteRouting)
                {
                    // Try to get the requested site by hostname & prefix
                    if (segments.Length > 0)
                    {
                        var prefixedHostname = $"{hostname}/{segments[0]}";
                        site = await api.Sites.GetByHostnameAsync(prefixedHostname)
                               .ConfigureAwait(false);

                        if (site != null)
                        {
                            context.Request.Path = "/" + string.Join("/", segments.Skip(1));
                            hostname             = prefixedHostname;
                            pos = 1;
                        }
                    }

                    // Try to get the requested site by hostname
                    if (site == null)
                    {
                        site = await api.Sites.GetByHostnameAsync(context.Request.Host.Host)
                               .ConfigureAwait(false);
                    }
                }

                // If we didn't find the site, get the default site
                if (site == null)
                {
                    site = await api.Sites.GetDefaultAsync()
                           .ConfigureAwait(false);
                }

                if (site != null)
                {
                    // Update application service
                    service.Site.Id      = site.Id;
                    service.Site.Culture = site.Culture;
                    service.Site.Sitemap = await api.Sites.GetSitemapAsync(site.Id);

                    // Set current culture if specified in site
                    if (!string.IsNullOrEmpty(site.Culture))
                    {
                        var cultureInfo = new CultureInfo(service.Site.Culture);
                        CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = cultureInfo;
                    }
                }
                else
                {
                    // There's no sites available, let the application finish
                    await _next.Invoke(context);

                    return;
                }

                // Store hostname
                service.Hostname = hostname;

                //
                // Check if we shouldn't handle empty requests for start page
                //
                if (segments.Length == 0 && !_config.UseStartpageRouting)
                {
                    await _next.Invoke(context);

                    return;
                }

                //
                // 3: Check for alias
                //
                if (_config.UseAliasRouting && segments.Length > pos)
                {
                    var alias = await api.Aliases.GetByAliasUrlAsync($"/{ string.Join("/", segments.Subset(pos)) }", service.Site.Id);

                    if (alias != null)
                    {
                        context.Response.Redirect(alias.RedirectUrl, alias.Type == RedirectType.Permanent);
                        return;
                    }
                }

                //
                // 4: Get the current page
                //
                PageBase page     = null;
                PageType pageType = null;

                if (segments.Length > pos)
                {
                    // Scan for the most unique slug
                    for (var n = segments.Length; n > pos; n--)
                    {
                        var slug = string.Join("/", segments.Subset(pos, n));
                        page = await api.Pages.GetBySlugAsync <PageBase>(slug, site.Id)
                               .ConfigureAwait(false);

                        if (page != null)
                        {
                            pos = pos + n;
                            break;
                        }
                    }
                }
                else
                {
                    page = await api.Pages.GetStartpageAsync <PageBase>(site.Id)
                           .ConfigureAwait(false);
                }

                if (page != null)
                {
                    pageType       = App.PageTypes.GetById(page.TypeId);
                    service.PageId = page.Id;

                    // Only cache published pages
                    if (page.IsPublished)
                    {
                        service.CurrentPage = page;
                    }
                }

                //
                // 5: Get the current post
                //
                PostBase post = null;

                if (_config.UsePostRouting)
                {
                    if (page != null && pageType.IsArchive && segments.Length > pos)
                    {
                        post = await api.Posts.GetBySlugAsync <PostBase>(page.Id, segments[pos])
                               .ConfigureAwait(false);

                        if (post != null)
                        {
                            pos++;
                        }
                    }

                    if (post != null)
                    {
                        App.PostTypes.GetById(post.TypeId);

                        // Onlyc cache published posts
                        if (post.IsPublished)
                        {
                            service.CurrentPost = post;
                        }
                    }
                }

                _logger?.LogDebug($"Found Site: [{ site.Id }]");
                if (page != null)
                {
                    _logger?.LogDebug($"Found Page: [{ page.Id }]");
                }

                if (post != null)
                {
                    _logger?.LogDebug($"Found Post: [{ post.Id }]");
                }

                //
                // 6: Route request
                //
                var route = new StringBuilder();
                var query = new StringBuilder();

                if (post != null)
                {
                    if (string.IsNullOrWhiteSpace(post.RedirectUrl))
                    {
                        // Handle HTTP caching
                        if (HandleCache(context, site, post, appConfig.CacheExpiresPosts))
                        {
                            // Client has latest version
                            return;
                        }

                        route.Append(post.Route ?? "/post");
                        for (var n = pos; n < segments.Length; n++)
                        {
                            route.Append("/");
                            route.Append(segments[n]);
                        }

                        query.Append("id=");
                        query.Append(post.Id);
                    }
                    else
                    {
                        _logger?.LogDebug($"Setting redirect: [{ post.RedirectUrl }]");

                        context.Response.Redirect(post.RedirectUrl, post.RedirectType == RedirectType.Permanent);
                        return;
                    }
                }
                else if (page != null && _config.UsePageRouting)
                {
                    if (string.IsNullOrWhiteSpace(page.RedirectUrl))
                    {
                        route.Append(page.Route ?? (pageType.IsArchive ? "/archive" : "/page"));

                        // Set the basic query
                        query.Append("id=");
                        query.Append(page.Id);

                        if (!page.ParentId.HasValue && page.SortOrder == 0)
                        {
                            query.Append("&startpage=true");
                        }

                        if (!pageType.IsArchive)
                        {
                            if (HandleCache(context, site, page, appConfig.CacheExpiresPages))
                            {
                                // Client has latest version.
                                return;
                            }

                            // This is a regular page, append trailing segments
                            for (var n = pos; n < segments.Length; n++)
                            {
                                route.Append("/");
                                route.Append(segments[n]);
                            }
                        }
                        else if (post == null)
                        {
                            // This is an archive, check for archive params
                            int? year          = null;
                            bool foundCategory = false;
                            bool foundTag      = false;
                            bool foundPage     = false;

                            for (var n = pos; n < segments.Length; n++)
                            {
                                if (segments[n] == "category" && !foundPage)
                                {
                                    foundCategory = true;
                                    continue;
                                }

                                if (segments[n] == "tag" && !foundPage && !foundCategory)
                                {
                                    foundTag = true;
                                    continue;
                                }

                                if (segments[n] == "page")
                                {
                                    foundPage = true;
                                    continue;
                                }

                                if (foundCategory)
                                {
                                    try
                                    {
                                        var categoryId = (await api.Posts.GetCategoryBySlugAsync(page.Id, segments[n]).ConfigureAwait(false))?.Id;

                                        if (categoryId.HasValue)
                                        {
                                            query.Append("&category=");
                                            query.Append(categoryId);
                                        }
                                    }
                                    finally
                                    {
                                        foundCategory = false;
                                    }
                                }

                                if (foundTag)
                                {
                                    try
                                    {
                                        var tagId = (await api.Posts.GetTagBySlugAsync(page.Id, segments[n]).ConfigureAwait(false))?.Id;

                                        if (tagId.HasValue)
                                        {
                                            query.Append("&tag=");
                                            query.Append(tagId);
                                        }
                                    }
                                    finally
                                    {
                                        foundTag = false;
                                    }
                                }

                                if (foundPage)
                                {
                                    try
                                    {
                                        var pageNum = Convert.ToInt32(segments[n]);
                                        query.Append("&page=");
                                        query.Append(pageNum);
                                        query.Append("&pagenum=");
                                        query.Append(pageNum);
                                    }
                                    catch
                                    {
                                        // We don't care about the exception, we just
                                        // discard malformed input
                                    }
                                    // Page number should always be last, break the loop
                                    break;
                                }

                                if (!year.HasValue)
                                {
                                    try
                                    {
                                        year = Convert.ToInt32(segments[n]);

                                        if (year.Value > DateTime.Now.Year)
                                        {
                                            year = DateTime.Now.Year;
                                        }
                                        query.Append("&year=");
                                        query.Append(year);
                                    }
                                    catch
                                    {
                                        // We don't care about the exception, we just
                                        // discard malformed input
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        var month = Math.Max(Math.Min(Convert.ToInt32(segments[n]), 12), 1);
                                        query.Append("&month=");
                                        query.Append(month);
                                    }
                                    catch
                                    {
                                        // We don't care about the exception, we just
                                        // discard malformed input
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        _logger?.LogDebug($"Setting redirect: [{ page.RedirectUrl }]");

                        context.Response.Redirect(page.RedirectUrl, page.RedirectType == RedirectType.Permanent);
                        return;
                    }
                }

                if (route.Length > 0)
                {
                    var strRoute = route.ToString();
                    var strQuery = query.ToString();

                    _logger?.LogDebug($"Setting Route: [{ strRoute }]");
                    _logger?.LogDebug($"Setting Query: [{ strQuery }]");

                    context.Request.Path = new PathString(strRoute);
                    if (context.Request.QueryString.HasValue)
                    {
                        context.Request.QueryString =
                            new QueryString(context.Request.QueryString.Value + "&" + strQuery);
                    }
                    else
                    {
                        context.Request.QueryString =
                            new QueryString("?" + strQuery);
                    }
                }
            }
            await _next.Invoke(context);
        }
示例#35
0
 public StumbledRepositoryViewModel(IApplicationService applicationService, INetworkActivityService networkActivity)
     : base(applicationService, networkActivity)
 {
 }
示例#36
0
 public AppController(IApplicationService applicationService)
 {
     _applicationService = applicationService;
 }
示例#37
0
 public PushNotificationsService(IApplicationService applicationService)
 {
     _applicationService = applicationService;
 }
示例#38
0
        private readonly string _userId = Infrastructure.EntityFramework.DataSeeder.TestUser1Id.ToString(); //TODO: Remove after identity implementation

        public ApplicationsController(IApplicationService applicationService, IMapper mapper)
        {
            this.applicationService = applicationService;
            this.mapper             = mapper;
        }
 public PublicGistsViewModel(IApplicationService applicationService)
 {
     _applicationService = applicationService;
 }
示例#40
0
        public RepositoryViewModel(IApplicationService applicationService,
                                   IAccountsService accountsService, IActionMenuFactory actionMenuService)
        {
            ApplicationService = applicationService;
            _accountsService   = accountsService;

            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;
            });

            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.Username = RepositoryOwner;
                    NavigateTo(vm);
                }
                else
                {
                    var vm      = this.CreateViewModel <UserViewModel>();
                    vm.Username = RepositoryOwner;
                    NavigateTo(vm);
                }
            });

            PinCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Repository).Select(x => x != null));
            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.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName  = RepositoryName;
                NavigateTo(vm);
            });

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

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

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

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

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

            GoToCommitsCommand = ReactiveCommand.Create();
            GoToCommitsCommand.Subscribe(_ =>
            {
                if (Branches != null && Branches.Count == 1)
                {
                    var vm             = this.CreateViewModel <CommitsViewModel>();
                    vm.RepositoryOwner = RepositoryOwner;
                    vm.RepositoryName  = RepositoryName;
                    vm.Branch          = Repository == null ? null : Repository.DefaultBranch;
                    NavigateTo(vm);
                }
                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);
            });

            ShowMenuCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.Repository, x => x.IsStarred, x => x.IsWatched)
                .Select(x => x.Item1 != null && x.Item2 != null && x.Item3 != null),
                _ =>
            {
                var menu = actionMenuService.Create(Title);
                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);
                return(menu.Show());
            });

            var gotoWebUrl = new Action <string>(x =>
            {
                var vm = this.CreateViewModel <WebBrowserViewModel>();
                vm.Url = 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(t =>
            {
                var forceCacheInvalidation = t as bool?;

                var t1 = this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Get(),
                                           forceCacheInvalidation, response => Repository = response.Data);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetReadme(),
                                  forceCacheInvalidation, response => Readme = response.Data);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetBranches(),
                                  forceCacheInvalidation, response => Branches = response.Data);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].IsWatching(),
                                  forceCacheInvalidation, response => IsWatched = response.Data);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].IsStarred(),
                                  forceCacheInvalidation, response => IsStarred = response.Data);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetContributors(),
                                  forceCacheInvalidation, response => Contributors = response.Data.Count);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetLanguages(),
                                  forceCacheInvalidation, response => Languages = response.Data.Count);

                this.RequestModel(ApplicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetReleases(),
                                  forceCacheInvalidation, response => Releases = response.Data.Count);

                return(t1);
            });
        }
 public ApplicationFacade(IUnitOfWorkProvider unitOfWorkProvider, IApplicationService applicationService) : base(unitOfWorkProvider)
 {
     this.applicationService = applicationService;
 }
示例#42
0
 public AppleViewModel(IApplicationService application,
                       IAppleService apple)
 {
     _application = application;
     _apple       = apple;
 }
示例#43
0
        public IssueViewModel(IApplicationService applicationService, IShareService shareService)
        {
            _applicationService = applicationService;
            Comments            = new ReactiveList <IssueCommentModel>();
            Events = new ReactiveList <IssueEventModel>();
            var issuePresenceObservable = this.WhenAnyValue(x => x.Issue).Select(x => x != null);

            ShareCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Issue, x => x != null && !string.IsNullOrEmpty(x.HtmlUrl)));
            ShareCommand.Subscribe(_ => shareService.ShareUrl(Issue.HtmlUrl));

            AddCommentCommand = ReactiveCommand.Create();
            AddCommentCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel <CommentViewModel>();
                ReactiveUI.Legacy.ReactiveCommandMixins.RegisterAsyncTask(vm.SaveCommand, async t =>
                {
                    var issue   = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId];
                    var comment = await _applicationService.Client.ExecuteAsync(issue.CreateComment(vm.Comment));
                    Comments.Add(comment.Data);
                    vm.DismissCommand.ExecuteIfCan();
                });
                ShowViewModel(vm);
            });

            ToggleStateCommand = ReactiveCommand.CreateAsyncTask(issuePresenceObservable, async t =>
            {
                var close = string.Equals(Issue.State, "open", StringComparison.OrdinalIgnoreCase);
                try
                {
                    var issue = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[Issue.Number];
                    var data  = await _applicationService.Client.ExecuteAsync(issue.UpdateState(close ? "closed" : "open"));
                    Issue     = data.Data;
                }
                catch (Exception e)
                {
                    throw new Exception("Unable to " + (close ? "close" : "open") + " the item. " + e.Message, e);
                }
            });

            GoToEditCommand = ReactiveCommand.Create(issuePresenceObservable);
            GoToEditCommand.Subscribe(_ =>
            {
                var vm             = CreateViewModel <IssueEditViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName  = RepositoryName;
                vm.Id    = IssueId;
                vm.Issue = Issue;
                vm.WhenAnyValue(x => x.Issue).Skip(1).Subscribe(x => Issue = x);
                ShowViewModel(vm);
            });

            GoToAssigneeCommand = ReactiveCommand.Create(issuePresenceObservable);
            GoToAssigneeCommand.Subscribe(_ =>
            {
                var vm             = CreateViewModel <IssueAssignedToViewModel>();
                vm.SaveOnSelect    = true;
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName  = RepositoryName;
                vm.IssueId         = IssueId;
                vm.SelectedUser    = Issue.Assignee;
                vm.WhenAnyValue(x => x.SelectedUser).Subscribe(x =>
                {
                    Issue.Assignee = x;
                    this.RaisePropertyChanged("Issue");
                });
                ShowViewModel(vm);
            });

            GoToLabelsCommand = ReactiveCommand.Create(issuePresenceObservable);
            GoToLabelsCommand.Subscribe(_ =>
            {
                var vm             = CreateViewModel <IssueLabelsViewModel>();
                vm.SaveOnSelect    = true;
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName  = RepositoryName;
                vm.IssueId         = IssueId;
                vm.SelectedLabels.Reset(Issue.Labels);
                vm.WhenAnyValue(x => x.SelectedLabels).Subscribe(x =>
                {
                    Issue.Labels = x.ToList();
                    this.RaisePropertyChanged("Issue");
                });
                ShowViewModel(vm);
            });

            GoToMilestoneCommand = ReactiveCommand.Create(issuePresenceObservable);
            GoToMilestoneCommand.Subscribe(_ =>
            {
                var vm               = CreateViewModel <IssueMilestonesViewModel>();
                vm.SaveOnSelect      = true;
                vm.RepositoryOwner   = RepositoryOwner;
                vm.RepositoryName    = RepositoryName;
                vm.IssueId           = IssueId;
                vm.SelectedMilestone = Issue.Milestone;
                vm.WhenAnyValue(x => x.SelectedMilestone).Subscribe(x =>
                {
                    Issue.Milestone = x;
                    this.RaisePropertyChanged("Issue");
                });
                ShowViewModel(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var forceCacheInvalidation = t as bool?;
                var issue = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId];
                var t1    = this.RequestModel(issue.Get(), forceCacheInvalidation, response => Issue = response.Data);
                Comments.SimpleCollectionLoad(issue.GetComments(), forceCacheInvalidation).FireAndForget();
                Events.SimpleCollectionLoad(issue.GetEvents(), forceCacheInvalidation).FireAndForget();
                return(t1);
            });
        }
示例#44
0
 public ApplicationController(IApplicationService serviceAXA, IMapper mapper)
 {
     _serviceAXA = serviceAXA;
     _mapper     = mapper;
 }
 /// <summary>
 /// Initializes a new instance of the FavoritesMovieTabViewModel class.
 /// </summary>
 /// <param name="applicationService">Application state</param>
 /// <param name="movieService">Movie service</param>
 /// <param name="userService">Movie history service</param>
 public FavoritesMovieTabViewModel(IApplicationService applicationService, IMovieService movieService,
                                   IUserService userService)
     : base(applicationService, movieService, userService,
            () => LocalizationProviderHelper.GetLocalizedValue <string>("FavoritesTitleTab"))
 {
 }
示例#46
0
        public ApiModule(ILogService server, IApplicationService application)
            : base("/api")
        {
            Server = server ?? throw new ArgumentNullException(nameof(server));

            Application = application ?? throw new ArgumentNullException(nameof(application));

            Get["/"] = _ =>
            {
                var response = (Response)JsonConvert.SerializeObject(new { id = AssemblyInfo.Id, name = AssemblyInfo.Name, description = AssemblyInfo.Description, version = AssemblyInfo.Version, build = AssemblyInfo.Build, copyright = AssemblyInfo.Copyright, hash = AssemblyInfo.Hash });

                response.ContentType = "application/json";

                return(response);
            };

            Get["/apps"] = _ =>
            {
                var apps = Async.Execute(() => Application.GetApplications());

                var response = (Response)JsonConvert.SerializeObject(apps);

                response.ContentType = "application/json";

                return(response);
            };

            Get["/apps/{app}/logs"] = _ =>
            {
                var logs = Async.Execute <List <Log> >(() => Server.GetLogEntries(_.app, DateTime.Now.Subtract(new TimeSpan(1, 0, 0)), DateTime.Now));

                var response = (Response)JsonConvert.SerializeObject(logs);

                response.ContentType = "application/json";

                return(response);
            };

            Get["/apps/{app}/logs/{startDate}/{endDate}"] = _ =>
            {
                var start = DateTime.ParseExact(_.startDate, "yyyyMMddTHHmmss", null);

                var end = DateTime.ParseExact(_.endDate, "yyyyMMddTHHmmss", null);

                var logs = Async.Execute <List <Log> >(() => Server.GetLogEntries(_.app, start, end));

                var response = (Response)JsonConvert.SerializeObject(logs);

                response.ContentType = "application/json";

                return(response);
            };

            Get["/apps/{app}/logs/{startDate}/{endDate}/{searchTerm}"] = _ =>
            {
                var start = DateTime.ParseExact(_.startDate, "yyyyMMddTHHmmss", null);

                var end = DateTime.ParseExact(_.endDate, "yyyyMMddTHHmmss", null);

                var logs = Async.Execute <List <Log> >(() => Server.SearchLogEntries(_.app, start, end, _.searchTerm));

                var response = (Response)JsonConvert.SerializeObject(logs);

                response.ContentType = "application/json";

                return(response);
            };
        }
示例#47
0
 /// <summary>
 /// Initializes a new instance of the SearchMovieTabViewModel class.
 /// </summary>
 /// <param name="applicationService">Application state</param>
 /// <param name="showService">Show service</param>
 /// <param name="userService">The user service</param>
 public SearchShowTabViewModel(IApplicationService applicationService, IShowService showService,
                               IUserService userService)
     : base(applicationService, showService, userService,
            () => LocalizationProviderHelper.GetLocalizedValue <string>("SearchTitleTab"))
 {
 }
示例#48
0
 public UserViewModel(User user, IApplicationService applicationService = null)
     : this(user.Username, applicationService)
 {
     User = user;
 }
示例#49
0
 public SonarrService(IApplicationService applicationService, IFileService fileService, ILogger <SonarrService> logger)
 {
     this.applicationService = applicationService;
     this.fileService        = fileService;
     this.logger             = logger;
 }
 public RepositoriesWatchedViewModel(IApplicationService applicationService) : base(applicationService)
 {
     LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                                                   RepositoryCollection.SimpleCollectionLoad(
                                                       applicationService.Client.AuthenticatedUser.Repositories.GetWatching(), t as bool?));
 }
 /// <summary>
 /// 初始化应用程序控制器
 /// </summary>
 /// <param name="service">应用程序服务</param>
 public ApplicationController(IApplicationService service) : base(service)
 {
 }
示例#52
0
 public SectorsController(ApplicationDbContext context, ISectorService sectorService, ISecurityService securityService, IApplicationSectorService applicationSectorService, IApplicationService applicationService) : base(securityService)
 {
     _context                  = context;
     _sectorService            = sectorService;
     _applicationSectorService = applicationSectorService;
     _applicationService       = applicationService;
 }
示例#53
0
 public PersonalController(
     IApplicationService _applicationService) : base()
 {
     this._applicationService = _applicationService;
 }
 public StudentAccountController(IApplicationService applicationService, IAuthenticationService authenticationService)
 {
     _applicationService    = applicationService;
     _authenticationService = authenticationService;
 }
示例#55
0
 public ApplicationsController(IApplicationService applicationService, IMapper mapper)
 {
     _applicationService = applicationService;
     _mapper             = mapper;
 }
示例#56
0
        public OrganizationViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            this.WhenAnyValue(x => x.Organization, x => x.Username,
                              (x, y) => x == null ? y : (string.IsNullOrEmpty(x.Name) ? x.Login : x.Name))
            .Select(x => x ?? "Organization")
            .Subscribe(x => Title = x);

            GoToMembersCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm = CreateViewModel <OrganizationMembersViewModel>();
                vm.OrganizationName = Username;
                ShowViewModel(vm);
            });

            GoToTeamsCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm = CreateViewModel <TeamsViewModel>();
                vm.OrganizationName = Username;
                ShowViewModel(vm);
            });

            GoToFollowersCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm      = CreateViewModel <UserFollowersViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToFollowingCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm      = CreateViewModel <UserFollowingsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToEventsCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm      = CreateViewModel <UserEventsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToGistsCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm      = CreateViewModel <UserGistsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToRepositoriesCommand = ReactiveCommand.Create().WithSubscription(_ =>
            {
                var vm  = CreateViewModel <OrganizationRepositoriesViewModel>();
                vm.Name = Username;
                ShowViewModel(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ =>
                                                          Organization = await _applicationService.GitHubClient.Organization.Get(Username));
        }
示例#57
0
        public ApplicationControllerTests()
        {
            defaultAppRegistryDataService = A.Fake <IAppRegistryDataService>();
            defaultMapper             = new ApplicationToPageModelMapper(defaultAppRegistryDataService);
            defaultLogger             = A.Fake <ILogger <ApplicationController> >();
            defaultApplicationService = A.Fake <IApplicationService>();
            defaultVersionedFiles     = A.Fake <IVersionedFiles>();
            defaultConfiguration      = A.Fake <IConfiguration>();
            defaultBaseUrlService     = A.Fake <IBaseUrlService>();
            neo4JService = A.Fake <INeo4JService>();

            defaultApplicationModel = new ApplicationModel
            {
                AppRegistrationModel = new AppRegistrationModel
                {
                    Path    = ChildAppPath,
                    Regions = new List <RegionModel>
                    {
                        new RegionModel
                        {
                            IsHealthy      = true,
                            PageRegion     = PageRegion.Body,
                            RegionEndpoint = "http://childApp/bodyRegion",
                        },
                    },
                },
            };
            defaultPostRequestViewModel = new ActionPostRequestModel
            {
                Path           = ChildAppPath,
                Data           = ChildAppData,
                FormCollection = new FormCollection(new Dictionary <string, StringValues>
                {
                    { "someKey", "someFormValue" },
                }),
            };
            childAppActionGetRequestModel = defaultPostRequestViewModel;
            A.CallTo(() => defaultApplicationService.GetApplicationAsync(childAppActionGetRequestModel)).Returns(defaultApplicationModel);

            var fakeHttpContext = new DefaultHttpContext {
                Request = { QueryString = QueryString.Create("test", "testvalue") }
            };

            defaultGetController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = fakeHttpContext,
                },
            };

            defaultPostController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        Request = { Method = "POST" },
                    },
                },
            };

            bearerTokenController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext {
                        User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> {
                            new Claim("bearer", "test")
                        }, "mock"))
                    },
                },
            };

            postBearerTokenController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext {
                        User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> {
                            new Claim("bearer", "test")
                        }, "mock"))
                    },
                },
            };
        }
 public ApplicationController()
 {
     _svc = new ApplicationService(new eFormSqlServerContext());
 }
示例#59
0
 protected CommandHttpApiBase(IApplicationService <TAggregate> service) => _service = service;
示例#60
0
 public ProductController(IProductService service, IMapper <Product, ProductInput> v, IFileManagerService fileManagerService, IUserService userService, IApplicationService applicationService, IRepo <ProductCategory> categoryService, IRepo <Product> productService)
     : base(service, v)
 {
     this.service            = service;
     this.userService        = userService;
     this.fileManagerService = fileManagerService;
     this.applicationService = applicationService;
     this.categoryService    = categoryService;
     this.productService     = productService;
 }