コード例 #1
0
        /// <summary>
        /// Stars a repository for the authenticated user.
        /// </summary>
        /// <param name="owner">The owner of the repository to star</param>
        /// <param name="name">The name of the repository to star</param>
        /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
        /// <returns>A <c>bool</c> representing the success of starring</returns>
        public IObservable<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            return _client.WatchRepo(owner, name, newSubscription).ToObservable();
        }
コード例 #2
0
        public PSLocalTask <NewSubscription, PimSubscriptionProxy> CreateNewSubscriptionTask(ExchangePrincipal executingUser)
        {
            NewSubscription task = new NewSubscription();

            this.InitializeTaskToExecuteInMode(executingUser, task, "New-Subscription", "Identity");
            return(new PSLocalTask <NewSubscription, PimSubscriptionProxy>(task));
        }
コード例 #3
0
        /// <summary>
        /// Stars a repository for the authenticated user.
        /// </summary>
        /// <param name="owner">The owner of the repository to star</param>
        /// <param name="name">The name of the repository to star</param>
        /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
        /// <returns>A <c>bool</c> representing the success of starring</returns>
        public IObservable <Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            return(_client.WatchRepo(owner, name, newSubscription).ToObservable());
        }
コード例 #4
0
 public async Task <Subscription> WatchRepository(long repositoryId, NewSubscription subscription, GitHubClient authorizedGitHubClient)
 {
     if (_watchedClient == null)
     {
         _watchedClient = new WatchedClient(new ApiConnection(authorizedGitHubClient.Connection));
     }
     return(await _watchedClient.WatchRepo(repositoryId, subscription));
 }
コード例 #5
0
        public IHttpActionResult PostSubscription([FromUri] NewSubscription subscription)
        {
            if (!ModelState.IsValid || subscription.EventNames.Count == 0)
            {
                return(BadRequest(ModelState));
            }
            // create a new subscription for each subscription that the user has specified
            foreach (var ev in subscription.EventNames)
            {
                var          today = DateTime.UtcNow;
                TimeZoneInfo tz    = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                today = TimeZoneInfo.ConvertTimeFromUtc(today, tz);
                Subscription sub = new Subscription()
                {
                    Username       = subscription.Username,
                    User           = db.Users.Select(x => x).Where(y => y.Username == subscription.Username) as User,
                    AssetID        = subscription.AssetID,
                    PlantID        = subscription.PlantID,
                    LineID         = subscription.LineID,
                    StartTime      = subscription.StartTime,
                    EndTime        = subscription.EndTime,
                    SubscriptionID = Guid.NewGuid(),
                    SubscribedOn   = today,
                    EventTypeName  = ev,
                    Days           = subscription.Days,
                    AuthToken      = db.Users.Where(y => y.Username == subscription.Username).Select(x => x.AuthToken).FirstOrDefault()
                };

                if (db.Subscriptions.Any(x => x.Username == sub.Username && x.EventTypeName == sub.EventTypeName && x.PlantID == sub.PlantID &&
                                         x.LineID == sub.LineID && x.AssetID == sub.AssetID))
                {
                    // sub already exists for (username, plant, line, asset, eventtypename)
                    return(BadRequest(ModelState));
                }

                db.Subscriptions.Add(sub);

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    if (SubscriptionExists(sub.SubscriptionID))
                    {
                        return(Conflict());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(Ok());
        }
コード例 #6
0
            public void EnsuresNonNullArguments()
            {
                var client       = new ObservableWatchedClient(Substitute.For <IGitHubClient>());
                var subscription = new NewSubscription();

                Assert.Throws <ArgumentNullException>(() => client.WatchRepo(null, "name", subscription));
                Assert.Throws <ArgumentNullException>(() => client.WatchRepo("owner", null, subscription));
                Assert.Throws <ArgumentException>(() => client.WatchRepo("", "name", subscription));
                Assert.Throws <ArgumentException>(() => client.WatchRepo("owner", "", subscription));
            }
コード例 #7
0
ファイル: RestAPI.cs プロジェクト: Sire/neteller-rest-api
        public SubscriptionThin CreateSubscription(NewSubscription newSub, string accessToken)
        {
            var request = new RestRequest("v1/subscriptions", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddBody(newSub);
            //send in specified accessToken that has access to creating subscription on customer account
            SubscriptionThin response = Execute <SubscriptionThin>(request, accessToken);

            return(response);
        }
コード例 #8
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new WatchedClient(connection);

                var newSubscription = new NewSubscription();
                client.WatchRepo("fight", "club", newSubscription);

                connection.Received().Put<Subscription>(endpoint, newSubscription);
            }
コード例 #9
0
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var endpoint   = new Uri("repositories/1/subscription", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new WatchedClient(connection);

                var newSubscription = new NewSubscription();

                client.WatchRepo(1, newSubscription);

                connection.Received().Put <Subscription>(endpoint, newSubscription);
            }
コード例 #10
0
ファイル: MainWindow.xaml.cs プロジェクト: andr9528/Unipay
        private void NewSubscription_Click(object sender, RoutedEventArgs e)
        {
            NewSubscription newsub = new NewSubscription();

            newsub.Title = "Opret";

            newsub.ShowDialog();

            data.ExportBackup();

            UpdateView();
        }
コード例 #11
0
ファイル: WatchedClientTests.cs プロジェクト: amenkes/sniper
            public async Task WatchRepoWithRepositoryId()
            {
                var newSubscription = new NewSubscription();

                await _watchingClient.UnwatchRepo(18221276);

                var subscription = await _watchingClient.WatchRepo(18221276, newSubscription);

                Assert.NotNull(subscription);

                var newWatchers = await _watchingClient.GetAllWatchers(18221276);

                var @default = newWatchers.FirstOrDefault(user => user.Login == Helper.UserName);

                Assert.NotNull(@default);
            }
コード例 #12
0
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Owner != null && Name != null && NewSubscription != null)
            {
                var ownerValue           = Owner.GetValue(dc.State);
                var nameValue            = Name.GetValue(dc.State);
                var newSubscriptionValue = NewSubscription.GetValue(dc.State);
                return(await gitHubClient.Activity.Watching.WatchRepo(ownerValue, nameValue, newSubscriptionValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && NewSubscription != null)
            {
                var repositoryIdValue    = RepositoryId.GetValue(dc.State);
                var newSubscriptionValue = NewSubscription.GetValue(dc.State);
                return(await gitHubClient.Activity.Watching.WatchRepo((Int64)repositoryIdValue, newSubscriptionValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [newSubscription] arguments missing for GitHubClient.Activity.Watching.WatchRepo");
        }
コード例 #13
0
ファイル: WatchedClientTests.cs プロジェクト: amenkes/sniper
            public async Task WatchRepo()
            {
                var newSubscription = new NewSubscription
                {
                    Subscribed = true
                };

                await _watchingClient.UnwatchRepo("octocat", "hello-worId");

                var subscription = await _watchingClient.WatchRepo("octocat", "hello-worId", newSubscription);

                Assert.NotNull(subscription);

                var newWatchers = await _watchingClient.GetAllWatchers("octocat", "hello-worId");

                var @default = newWatchers.FirstOrDefault(user => user.Login == Helper.UserName);

                Assert.NotNull(@default);
            }
コード例 #14
0
            private ISubscription CreateSubscription(NewSubscription s)
            {
                var obs = mObservableInstancesCache
                          .WatchValue(s.ObservableId)
                          .Take(1)
                          .StartWith(cUnknownObservable);

                var streamEvents = mStreamEventsBySubscription
                                   .WatchValue(s.Subscribed.SequenceId)
                                   .Take(1)
                                   .SelectMany(es => es);

                var unsubscribeEvent = mSubscriptionDisposalsCache
                                       .WatchValue(s.Subscribed.SequenceId)
                                       .Take(1);

                var allEvents = streamEvents
                                .Merge(unsubscribeEvent)
                                .StartWith(new SubscribeEvent(s.Subscribed));

                return(new Subscription(s.Subscribed.SequenceId, obs, allEvents));
            }
コード例 #15
0
 public async Task <Subscription> WatchRepository(long repositoryId, NewSubscription subscription, GitHubClient authorizedGitHubClient)
 {
     return(await _repoRepository.WatchRepository(repositoryId, subscription, authorizedGitHubClient));
 }
コード例 #16
0
            public async Task WatchRepo()
            {
                var newSubscription = new NewSubscription
                {
                    Subscribed = true
                };

                await _watchingClient.UnwatchRepo("octocat", "hello-worId");

                var subscription = await _watchingClient.WatchRepo("octocat", "hello-worId", newSubscription);
                Assert.NotNull(subscription);

                await _watchingClient.UnwatchRepo("octocat", "hello-worId");

                var newWatchers = await _watchingClient.GetAllWatchers("octocat", "hello-worId");
                var @default = newWatchers.FirstOrDefault(user => user.Login == Helper.UserName);
                Assert.Null(@default);
            }
コード例 #17
0
        /// <summary>
        /// Stars a repository for the authenticated user.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
        public IObservable <Subscription> WatchRepo(int repositoryId, NewSubscription newSubscription)
        {
            Ensure.ArgumentNotNull(newSubscription, "newSubscription");

            return(_client.WatchRepo(repositoryId, newSubscription).ToObservable());
        }
コード例 #18
0
            public async Task WatchRepoWithRepositoryId()
            {
                var newSubscription = new NewSubscription();

                await _watchingClient.UnwatchRepo(18221276);

                var subscription = await _watchingClient.WatchRepo(18221276, newSubscription);
                Assert.NotNull(subscription);

                await _watchingClient.UnwatchRepo(18221276);

                var newWatchers = await _watchingClient.GetAllWatchers(18221276);
                var @default = newWatchers.FirstOrDefault(user => user.Login == Helper.UserName);
                Assert.Null(@default);
            }
コード例 #19
0
        /// <summary>
        /// Stars a repository for the authenticated user.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
        public IObservable<Subscription> WatchRepo(long repositoryId, NewSubscription newSubscription)
        {
            Ensure.ArgumentNotNull(newSubscription, "newSubscription");

            return _client.WatchRepo(repositoryId, newSubscription).ToObservable();
        }
コード例 #20
0
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableWatchedClient(Substitute.For<IGitHubClient>());
                var subscription = new NewSubscription();

                Assert.Throws<ArgumentNullException>(() => client.WatchRepo(null, "name", subscription));
                Assert.Throws<ArgumentNullException>(() => client.WatchRepo("owner", null, subscription));
                Assert.Throws<ArgumentException>(() => client.WatchRepo("", "name", subscription));
                Assert.Throws<ArgumentException>(() => client.WatchRepo("owner", "", subscription));
            }