public override async Task <IActionResult> UpdateSubscription(Guid id, [FromBody] v2018_07_16.Models.SubscriptionUpdate update) { Data.Models.Subscription subscription = await _context.Subscriptions.Where(sub => sub.Id == id) .FirstOrDefaultAsync(); if (subscription == null) { return(NotFound()); } var doUpdate = false; if (!string.IsNullOrEmpty(update.SourceRepository)) { subscription.SourceRepository = update.SourceRepository; doUpdate = true; } if (update.Policy != null) { subscription.PolicyObject = update.Policy.ToDb(); doUpdate = true; } if (!string.IsNullOrEmpty(update.ChannelName)) { Data.Models.Channel channel = await _context.Channels.Where(c => c.Name == update.ChannelName) .FirstOrDefaultAsync(); if (channel == null) { return(BadRequest( new ApiError( "The request is invalid", new[] { $"The channel '{update.ChannelName}' could not be found." }))); } subscription.Channel = channel; doUpdate = true; } if (update.Enabled.HasValue) { subscription.Enabled = update.Enabled.Value; doUpdate = true; } if (doUpdate) { _context.Subscriptions.Update(subscription); await _context.SaveChangesAsync(); } return(Ok(new Subscription(subscription))); }
public override sealed Task <IActionResult> UpdateSubscription(Guid id, [FromBody] v2018_07_16.Models.SubscriptionUpdate update) { throw new NotImplementedException(); }