Skip to content

Commit

Permalink
Get PlanID from Plan Repo
Browse files Browse the repository at this point in the history
  • Loading branch information
msalemcode committed Jan 10, 2025
1 parent 8333403 commit 21c219b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/AdminSite/Controllers/SchedulerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public class SchedulerController : BaseController
/// </summary>
private SubscriptionService subscriptionService;

/// <summary>
/// the plan service
/// </summary>
private IPlansRepository plansRepository;

/// <summary>
/// the user repository
/// </summary>
Expand Down Expand Up @@ -74,7 +79,7 @@ public SchedulerController(
this.meteredRepository = meteredRepository;
this.schedulerService = new MeteredPlanSchedulerManagementService(frequencyRepository, schedulerRepository, schedulerViewRepository,subscriptionUsageLogsRepository,applicationConfigRepository);
this.subscriptionService = new SubscriptionService(subscriptionRepository,plansRepository);

this.plansRepository = plansRepository;
}

/// <summary>
Expand Down Expand Up @@ -134,8 +139,6 @@ public IActionResult NewScheduler(string subscriptionId, string dimId, string qu
Value = item.Id.ToString(),
});
}
// Create Plan Dropdown list
List<SelectListItem> PlanList = new List<SelectListItem>();
List<SelectListItem> DimensionsList = new List<SelectListItem>();

schedulerUsageViewModel.DimensionsList = new SelectList(DimensionsList, "Value", "Text");
Expand Down Expand Up @@ -228,13 +231,18 @@ public IActionResult AddNewScheduledTrigger(SchedulerUsageViewModel schedulerUsa
{
try
{
var selectedDimension = this.meteredRepository.Get(int.Parse(schedulerUsageViewModel.SelectedDimension));
//Get AMP Plan ID from Subscription Detail
var subscriptionDetail = this.subscriptionService.GetActiveSubscriptionsWithMeteredPlan().Where(s => s.Id == Convert.ToInt32(schedulerUsageViewModel.SelectedSubscription)).FirstOrDefault();
// Get Plan detail by AMP Plan ID
var selectedPlan = this.plansRepository.GetById(subscriptionDetail.AmpplanId);


MeteredPlanSchedulerManagementModel schedulerManagement = new MeteredPlanSchedulerManagementModel()
{
FrequencyId = Convert.ToInt32(schedulerUsageViewModel.SelectedSchedulerFrequency),
SchedulerName = Convert.ToString(schedulerUsageViewModel.SchedulerName),
SubscriptionId = Convert.ToInt32(schedulerUsageViewModel.SelectedSubscription),
PlanId = Convert.ToInt32(selectedDimension.PlanId),
PlanId = Convert.ToInt32(selectedPlan.Id),
DimensionId = Convert.ToInt32(schedulerUsageViewModel.SelectedDimension),
Quantity = Convert.ToDouble(schedulerUsageViewModel.Quantity),
StartDate = schedulerUsageViewModel.FirstRunDate.AddHours(schedulerUsageViewModel.TimezoneOffset)
Expand Down

0 comments on commit 21c219b

Please sign in to comment.