Example #1
0
 public async Task <IActionResult> DropPlan([FromRoute(Name = "planId")] int planId)
 {
     return(await plans.FetchSubscriptionPlan(planId)
            .Ensure(plan => plan.HasValue, "Plan was found")
            .OnSuccess(async plan =>
     {
         await billingManager.DeleteSubscription(plan.Value.ExternalPlanId).ConfigureAwait(false);
         await plans.DropSubscriptionPlan(plan.Value.PlanId).ConfigureAwait(false);
     })
            .OnBoth(p => p.IsFailure ? StatusCode(404) : StatusCode(200))
            .ConfigureAwait(false));
 }