/// <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(); }
public PSLocalTask <NewSubscription, PimSubscriptionProxy> CreateNewSubscriptionTask(ExchangePrincipal executingUser) { NewSubscription task = new NewSubscription(); this.InitializeTaskToExecuteInMode(executingUser, task, "New-Subscription", "Identity"); return(new PSLocalTask <NewSubscription, PimSubscriptionProxy>(task)); }
/// <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()); }
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)); }
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()); }
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)); }
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); }
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); }
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); }
private void NewSubscription_Click(object sender, RoutedEventArgs e) { NewSubscription newsub = new NewSubscription(); newsub.Title = "Opret"; newsub.ShowDialog(); data.ExportBackup(); UpdateView(); }
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); }
/// <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"); }
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); }
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)); }
public async Task <Subscription> WatchRepository(long repositoryId, NewSubscription subscription, GitHubClient authorizedGitHubClient) { return(await _repoRepository.WatchRepository(repositoryId, subscription, authorizedGitHubClient)); }
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); }
/// <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()); }
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); }
/// <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(); }
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)); }