/// <summary> /// Gets all plans within an offer. /// </summary> /// <param name="offerName">The name of the offer.</param> /// <returns>A list of plans.</returns> public async Task <List <Plan> > GetAllAsync(string offerName) { _logger.LogInformation(LoggingUtils.ComposeGetAllResourcesMessage(typeof(Plan).Name, offerName: offerName)); // Get the offer associated with the offerName provided var offer = await _offerService.GetAsync(offerName); // Get all plans with a FK to the offer var plans = await _context.Plans.Where(p => p.OfferId == offer.Id).ToListAsync(); List <Plan> result = new List <Plan>(); // Set each plan's ARM template Names foreach (Plan plan in plans) { result.Add(await SetArmTemplateAndWebhookNames(plan)); } _logger.LogInformation(LoggingUtils.ComposeReturnCountMessage(typeof(Plan).Name, plans.Count())); return(result); }
/// <summary> /// Gets all customMeters. /// </summary> /// <param name="offerName">The offer name of the customMeter.</param> /// <returns>A list of customMeters.</returns> public async Task <List <CustomMeter> > GetAllAsync(string offerName) { _logger.LogInformation(LoggingUtils.ComposeGetAllResourcesMessage(typeof(CustomMeter).Name, offerName: offerName)); var offer = await _offerService.GetAsync(offerName); // Get all customMeters from db var customMeters = await _context.CustomMeters.Where(c => c.OfferId == offer.Id).ToListAsync(); foreach (var meter in customMeters) { meter.OfferName = offerName; var connector = await _context.TelemetryDataConnectors.FindAsync(meter.TelemetryDataConnectorId); meter.TelemetryDataConnectorName = connector.Name; } _logger.LogInformation(LoggingUtils.ComposeReturnCountMessage(typeof(CustomMeter).Name, customMeters.Count())); return(customMeters); }
public async Task <ActionResult> GetAllAsync() { _logger.LogInformation(LoggingUtils.ComposeGetAllResourcesMessage(typeof(Subscription).Name)); string owner = ""; if (Request.Query.ContainsKey("owner")) { owner = Request.Query["owner"].ToString(); _logger.LogInformation($"Subscription owner name: {owner}."); AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, false, owner); } else { // user can only query their own subscriptions AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true); } string[] statusList = null; if (Request.Query.ContainsKey("status")) { var status = Request.Query["status"].ToString(); object statusEnum; if (Enum.TryParse(typeof(FulfillmentState), status, true, out statusEnum)) { _logger.LogInformation($"Getting subscriptions in {status} state."); statusList = new string[] { status }; } else { _logger.LogInformation($"Getting active subscriptions only"); statusList = new string[] { nameof(FulfillmentState.PendingFulfillmentStart), nameof(FulfillmentState.Subscribed), nameof(FulfillmentState.Suspended) }; } } return(Ok(await _subscriptionService.GetAllAsync(status: statusList, owner: owner))); }
public async Task <ActionResult> GetAllAsync(string offerName) { AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true); _logger.LogInformation(LoggingUtils.ComposeGetAllResourcesMessage(typeof(ArmTemplate).Name, offerName: offerName)); return(Ok(await _armTemplateService.GetAllAsync(offerName))); }