public virtual async Task <IActionResult> TriggerSubscription(Guid id) { Data.Models.Subscription subscription = await _context.Subscriptions.Include(sub => sub.LastAppliedBuild) .Include(sub => sub.Channel) .FirstOrDefaultAsync(sub => sub.Id == id); if (subscription == null) { return(NotFound()); } _queue.Post( async() => { await _dependencyUpdater.StartSubscriptionUpdateAsync(id); }); return(Accepted(new Subscription(subscription))); }
public async Task <IActionResult> RetrySubscriptionActionAsync(Guid id, long timestamp) { DateTime ts = DateTimeOffset.FromUnixTimeSeconds(timestamp).UtcDateTime; Data.Models.Subscription subscription = await _context.Subscriptions.Where(sub => sub.Id == id) .FirstOrDefaultAsync(); if (subscription == null) { return(NotFound()); } var update = await _context.SubscriptionUpdateHistory .Where(u => u.SubscriptionId == id) .FirstOrDefaultAsync(u => Math.Abs(EF.Functions.DateDiffSecond(u.Timestamp, ts)) < 1); if (update == null) { return(NotFound()); } if (update.Success) { return(StatusCode( (int)HttpStatusCode.NotAcceptable, new ApiError("That action was successful, it cannot be retried."))); } _queue.Post( async() => { var actor = _subscriptionActorFactory(new ActorId(subscription.Id)); await actor.RunAction(update.Method, update.Arguments); }); return(Accepted()); }