Skip to content

Commit

Permalink
Add Null check
Browse files Browse the repository at this point in the history
  • Loading branch information
msalemcode committed Jan 10, 2025
1 parent 21c219b commit 2d64451
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/AdminSite/Controllers/SchedulerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,22 @@ public IActionResult AddNewScheduledTrigger(SchedulerUsageViewModel schedulerUsa
{
try
{
//Get AMP Plan ID from Subscription Detail
//Retrieve the active subscription detail to get the AMP Plan ID
var subscriptionDetail = this.subscriptionService.GetActiveSubscriptionsWithMeteredPlan().Where(s => s.Id == Convert.ToInt32(schedulerUsageViewModel.SelectedSubscription)).FirstOrDefault();
// Get Plan detail by AMP Plan ID
// Check if subscriptionDetail is null
if (subscriptionDetail == null)
{
this.logger.LogError("Subscription detail not found for the given subscription ID.");
return this.View("Error", "Subscription detail not found.");
}
// Retrieve the active Plan detail by AMP Plan ID
var selectedPlan = this.plansRepository.GetById(subscriptionDetail.AmpplanId);

// Check if subscriptionDetail is null
if (selectedPlan == null)
{
this.logger.LogError("Plan detail not found for the given subscription.");
return this.View("Error", "Plan detail not found.");
}

MeteredPlanSchedulerManagementModel schedulerManagement = new MeteredPlanSchedulerManagementModel()
{
Expand Down

0 comments on commit 2d64451

Please sign in to comment.