mirror of
https://github.com/bitwarden/server.git
synced 2025-04-18 19:48:12 -05:00

* Replace SubscriberQueries with SubscriberService * Replace OrganizationBillingQueries with OrganizationBillingService * Replace ProviderBillingQueries with ProviderBillingService, move to Commercial * Replace AssignSeatsToClientOrganizationCommand with ProviderBillingService, move to commercial * Replace ScaleSeatsCommand with ProviderBillingService and move to Commercial * Replace CancelSubscriptionCommand with SubscriberService * Replace CreateCustomerCommand with ProviderBillingService and move to Commercial * Replace StartSubscriptionCommand with ProviderBillingService and moved to Commercial * Replaced RemovePaymentMethodCommand with SubscriberService * Formatting * Used dotnet format this time * Changing ProviderBillingService to scoped * Found circular dependency' * One more time with feeling * Formatting * Fix error in remove org from provider * Missed test fix in conflit * [AC-1937] Server: Implement endpoint to retrieve provider payment information (#4107) * Move the gettax and paymentmethod from stripepayment class Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Add the method to retrieve the tax and payment details Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Add unit tests for the paymentInformation method Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Add the endpoint to retrieve paymentinformation Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Add unit tests to the SubscriberService Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Remove the getTaxInfoAsync update reference Signed-off-by: Cy Okeke <cokeke@bitwarden.com> --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com> --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com> Co-authored-by: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com>
70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
using Bit.Admin.Enums;
|
|
using Bit.Admin.Utilities;
|
|
using Bit.Core.AdminConsole.Providers.Interfaces;
|
|
using Bit.Core.AdminConsole.Repositories;
|
|
using Bit.Core.Exceptions;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Core.Utilities;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Bit.Admin.AdminConsole.Controllers;
|
|
|
|
[Authorize]
|
|
[SelfHosted(NotSelfHostedOnly = true)]
|
|
public class ProviderOrganizationsController : Controller
|
|
{
|
|
private readonly IProviderRepository _providerRepository;
|
|
private readonly IProviderOrganizationRepository _providerOrganizationRepository;
|
|
private readonly IOrganizationRepository _organizationRepository;
|
|
private readonly IRemoveOrganizationFromProviderCommand _removeOrganizationFromProviderCommand;
|
|
|
|
public ProviderOrganizationsController(IProviderRepository providerRepository,
|
|
IProviderOrganizationRepository providerOrganizationRepository,
|
|
IOrganizationRepository organizationRepository,
|
|
IRemoveOrganizationFromProviderCommand removeOrganizationFromProviderCommand)
|
|
{
|
|
_providerRepository = providerRepository;
|
|
_providerOrganizationRepository = providerOrganizationRepository;
|
|
_organizationRepository = organizationRepository;
|
|
_removeOrganizationFromProviderCommand = removeOrganizationFromProviderCommand;
|
|
}
|
|
|
|
[HttpPost]
|
|
[RequirePermission(Permission.Provider_Edit)]
|
|
public async Task<IActionResult> DeleteAsync(Guid providerId, Guid id)
|
|
{
|
|
var provider = await _providerRepository.GetByIdAsync(providerId);
|
|
if (provider is null)
|
|
{
|
|
return RedirectToAction("Index", "Providers");
|
|
}
|
|
|
|
var providerOrganization = await _providerOrganizationRepository.GetByIdAsync(id);
|
|
if (providerOrganization is null)
|
|
{
|
|
return RedirectToAction("View", "Providers", new { id = providerId });
|
|
}
|
|
|
|
var organization = await _organizationRepository.GetByIdAsync(providerOrganization.OrganizationId);
|
|
if (organization == null)
|
|
{
|
|
return RedirectToAction("View", "Providers", new { id = providerId });
|
|
}
|
|
|
|
try
|
|
{
|
|
await _removeOrganizationFromProviderCommand.RemoveOrganizationFromProvider(
|
|
provider,
|
|
providerOrganization,
|
|
organization);
|
|
}
|
|
catch (BadRequestException ex)
|
|
{
|
|
return BadRequest(ex.Message);
|
|
}
|
|
|
|
return Json(null);
|
|
}
|
|
}
|