1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-26 03:31:34 +01:00

resolve the issue (#4035)

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
cyprain-okeke 2024-04-30 19:20:48 +01:00 committed by GitHub
parent 8e7bd79d9a
commit 3749fa6113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ using Bit.Core.AdminConsole.Services;
using Bit.Core.Billing.Entities;
using Bit.Core.Billing.Extensions;
using Bit.Core.Billing.Repositories;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Services;
@ -195,9 +196,25 @@ public class ProvidersController : Controller
}
model.ToProviderPlan(providerPlans);
foreach (var providerPlan in providerPlans)
if (providerPlans.Count == 0)
{
await _providerPlanRepository.ReplaceAsync(providerPlan);
var newProviderPlans = new List<ProviderPlan>
{
new() {ProviderId = provider.Id, PlanType = PlanType.TeamsMonthly, SeatMinimum= model.TeamsMinimumSeats, PurchasedSeats = 0, AllocatedSeats = 0},
new() {ProviderId = provider.Id, PlanType = PlanType.EnterpriseMonthly, SeatMinimum= model.EnterpriseMinimumSeats, PurchasedSeats = 0, AllocatedSeats = 0}
};
foreach (var newProviderPlan in newProviderPlans)
{
await _providerPlanRepository.CreateAsync(newProviderPlan);
}
}
else
{
foreach (var providerPlan in providerPlans)
{
await _providerPlanRepository.ReplaceAsync(providerPlan);
}
}
return RedirectToAction("Edit", new { id });