diff --git a/src/Admin/Admin.csproj b/src/Admin/Admin.csproj index 7e7f530986..d06d5ee310 100644 --- a/src/Admin/Admin.csproj +++ b/src/Admin/Admin.csproj @@ -16,4 +16,10 @@ + + + $(IncludeRazorContentInPack) + + + diff --git a/src/Admin/Controllers/OrganizationsController.cs b/src/Admin/Controllers/OrganizationsController.cs index ab1ea23deb..b6249e30fb 100644 --- a/src/Admin/Controllers/OrganizationsController.cs +++ b/src/Admin/Controllers/OrganizationsController.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using Bit.Core.Models.Table; using Bit.Core; using Bit.Core.Utilities; +using Bit.Core.Services; namespace Bit.Admin.Controllers { @@ -16,15 +17,18 @@ namespace Bit.Admin.Controllers { private readonly IOrganizationRepository _organizationRepository; private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly IPaymentService _paymentService; private readonly GlobalSettings _globalSettings; public OrganizationsController( IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, + IPaymentService paymentService, GlobalSettings globalSettings) { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; + _paymentService = paymentService; _globalSettings = globalSettings; } @@ -78,7 +82,8 @@ namespace Bit.Admin.Controllers } var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id); - return View(new OrganizationEditModel(organization, users, _globalSettings)); + var billingInfo = await _paymentService.GetBillingAsync(organization); + return View(new OrganizationEditModel(organization, users, billingInfo, _globalSettings)); } [HttpPost] diff --git a/src/Admin/Controllers/UsersController.cs b/src/Admin/Controllers/UsersController.cs index ef2716541e..19d2410296 100644 --- a/src/Admin/Controllers/UsersController.cs +++ b/src/Admin/Controllers/UsersController.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using Bit.Core.Models.Table; using Bit.Core; using Bit.Core.Utilities; +using Bit.Core.Services; namespace Bit.Admin.Controllers { @@ -16,15 +17,18 @@ namespace Bit.Admin.Controllers { private readonly IUserRepository _userRepository; private readonly ICipherRepository _cipherRepository; + private readonly IPaymentService _paymentService; private readonly GlobalSettings _globalSettings; public UsersController( IUserRepository userRepository, ICipherRepository cipherRepository, + IPaymentService paymentService, GlobalSettings globalSettings) { _userRepository = userRepository; _cipherRepository = cipherRepository; + _paymentService = paymentService; _globalSettings = globalSettings; } @@ -74,7 +78,8 @@ namespace Bit.Admin.Controllers } var ciphers = await _cipherRepository.GetManyByUserIdAsync(id); - return View(new UserEditModel(user, ciphers, _globalSettings)); + var billingInfo = await _paymentService.GetBillingAsync(user); + return View(new UserEditModel(user, ciphers, billingInfo, _globalSettings)); } [HttpPost] diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/Models/OrganizationEditModel.cs index 26481c2908..163136a406 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/Models/OrganizationEditModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Bit.Core; using Bit.Core.Enums; +using Bit.Core.Models.Business; using Bit.Core.Models.Data; using Bit.Core.Models.Table; using Bit.Core.Utilities; @@ -14,9 +15,10 @@ namespace Bit.Admin.Models public OrganizationEditModel() { } public OrganizationEditModel(Organization org, IEnumerable orgUsers, - GlobalSettings globalSettings) + BillingInfo billingInfo, GlobalSettings globalSettings) : base(org, orgUsers) { + BillingInfo = billingInfo; BraintreeMerchantId = globalSettings.Braintree.MerchantId; Name = org.Name; @@ -42,6 +44,7 @@ namespace Bit.Admin.Models ExpirationDate = org.ExpirationDate; } + public BillingInfo BillingInfo { get; set; } public string RandomLicenseKey => CoreHelpers.SecureRandomString(20); public string FourteenDayExpirationDate => DateTime.Now.AddDays(14).ToString("yyyy-MM-ddTHH:mm"); public string BraintreeMerchantId { get; set; } diff --git a/src/Admin/Models/TransactionViewModel.cs b/src/Admin/Models/TransactionViewModel.cs new file mode 100644 index 0000000000..a1a87530eb --- /dev/null +++ b/src/Admin/Models/TransactionViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Bit.Core.Models.Table; + +namespace Bit.Admin.Models +{ + public class TransactionViewModel + { + public TransactionViewModel() { } + + public TransactionViewModel(User user, IEnumerable ciphers) + { + + } + + + } +} diff --git a/src/Admin/Models/UserEditModel.cs b/src/Admin/Models/UserEditModel.cs index c2be10c26d..de8abef55b 100644 --- a/src/Admin/Models/UserEditModel.cs +++ b/src/Admin/Models/UserEditModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Bit.Core; +using Bit.Core.Models.Business; using Bit.Core.Models.Table; using Bit.Core.Utilities; @@ -11,9 +12,11 @@ namespace Bit.Admin.Models { public UserEditModel() { } - public UserEditModel(User user, IEnumerable ciphers, GlobalSettings globalSettings) + public UserEditModel(User user, IEnumerable ciphers, BillingInfo billingInfo, + GlobalSettings globalSettings) : base(user, ciphers) { + BillingInfo = billingInfo; BraintreeMerchantId = globalSettings.Braintree.MerchantId; Name = user.Name; @@ -28,6 +31,7 @@ namespace Bit.Admin.Models PremiumExpirationDate = user.PremiumExpirationDate; } + public BillingInfo BillingInfo { get; set; } public string RandomLicenseKey => CoreHelpers.SecureRandomString(20); public string OneYearExpirationDate => DateTime.Now.AddYears(1).ToString("yyyy-MM-ddTHH:mm"); public string BraintreeMerchantId { get; set; } diff --git a/src/Admin/Views/Organizations/Edit.cshtml b/src/Admin/Views/Organizations/Edit.cshtml index 989ae927c1..3eb99a934f 100644 --- a/src/Admin/Views/Organizations/Edit.cshtml +++ b/src/Admin/Views/Organizations/Edit.cshtml @@ -74,8 +74,10 @@

Organization @Model.Organization.Name

-

Information

+

Organization Information

@await Html.PartialAsync("_ViewInformation", Model) +

Billing Information

+@await Html.PartialAsync("_BillingInformation", Model.BillingInfo)

General

diff --git a/src/Admin/Views/Shared/_BillingInformation.cshtml b/src/Admin/Views/Shared/_BillingInformation.cshtml new file mode 100644 index 0000000000..3d3e040808 --- /dev/null +++ b/src/Admin/Views/Shared/_BillingInformation.cshtml @@ -0,0 +1,54 @@ +@model Bit.Core.Models.Business.BillingInfo +
+
Account @(Model.Balance <= 0 ? "Credit" : "Balance")
+
@Math.Abs(Model.Balance).ToString("C")
+ +
Invoices
+
+ @if(Model.Invoices?.Any() ?? false) + { + + + @foreach(var invoice in Model.Invoices) + { + + + + + + + } + +
@invoice.Date@invoice.Number@invoice.Amount.ToString("C")@(invoice.Paid ? "Paid" : "Unpaid")
+ } + else + { + @: No invoices. + } +
+ +
Transactions
+
+ @if(Model.Transactions?.Any() ?? false) + { + + + @foreach(var transaction in Model.Transactions) + { + + + + + + + + } + +
@transaction.CreatedDate@transaction.Type.ToString()@transaction.PaymentMethodType.ToString()@transaction.Details@transaction.Amount.ToString("C")
+ } + else + { + @: No transactions. + } +
+
diff --git a/src/Admin/Views/Users/Edit.cshtml b/src/Admin/Views/Users/Edit.cshtml index 808aaf2bc9..c25a5c99f6 100644 --- a/src/Admin/Views/Users/Edit.cshtml +++ b/src/Admin/Views/Users/Edit.cshtml @@ -56,8 +56,10 @@

User @Model.User.Email

-

Information

+

User Information

@await Html.PartialAsync("_ViewInformation", Model) +

Billing Information

+@await Html.PartialAsync("_BillingInformation", Model.BillingInfo)

General