Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
using Grand.Business.Core.Interfaces.Customers;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
using Grand.Mediator;
namespace Grand.Web.Features.Handlers.Customers;
public class GetSubAccountHandler : IRequestHandler<GetSubAccount, SubAccountEditModel>
{
private readonly ICustomerService _customerService;
public GetSubAccountHandler(ICustomerService customerService)
{
_customerService = customerService;
}
public async Task<SubAccountEditModel> Handle(GetSubAccount request, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(request.CurrentCustomer);
var model = new SubAccountEditModel();
var subaccount = await _customerService.GetCustomerById(request.CustomerId);
if (subaccount != null && subaccount.OwnerId == request.CurrentCustomer.Id)
model = new SubAccountEditModel {
Id = subaccount.Id,
Email = subaccount.Email,
Active = subaccount.Active,
FirstName = subaccount.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.FirstName),
LastName = subaccount.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.LastName)
};
return model;
}
}