From 45416c05342487858c5c76f4fe50fdd2599ec473 Mon Sep 17 00:00:00 2001 From: Cy Okeke Date: Thu, 1 May 2025 07:27:37 +0100 Subject: [PATCH] Refactor the code base on the pr comment Signed-off-by: Cy Okeke --- .../Controllers/OrganizationsController.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Admin/AdminConsole/Controllers/OrganizationsController.cs b/src/Admin/AdminConsole/Controllers/OrganizationsController.cs index fcfbe78833..fe43dd2e4c 100644 --- a/src/Admin/AdminConsole/Controllers/OrganizationsController.cs +++ b/src/Admin/AdminConsole/Controllers/OrganizationsController.cs @@ -257,8 +257,18 @@ public class OrganizationsController : Controller if (organization.PlanType != PlanType.Free && model.PlanType == PlanType.Free && model.Seats > 2) { - model.Seats = 2; - model.MaxCollections = 2; + TempData["Error"] = "Organizations with more than 2 seats cannot be downgraded to the Free plan"; + return RedirectToAction("Edit", new { id }); + } + + if (organization.PlanType != PlanType.Free && model.PlanType == PlanType.Free && model.MaxCollections > 2) + { + TempData["Error"] = $"Organizations with more than 2 collections cannot be downgraded to the Free plan. Your organization currently has {organization.MaxCollections} collections."; + return RedirectToAction("Edit", new { id }); + } + + if (organization.PlanType != PlanType.Free && model.PlanType == PlanType.Free) + { model.MaxStorageGb = null; model.ExpirationDate = null; model.Enabled = true;