I think if you redraw the datatables fnRowCallback
will be executed and it renders rowActions
https://github.com/abpframework/abp/blob/1ccf95f161372353e2ee6027d983739e6b9fb12b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js#L270
You can override the IdentityUserAppService
's Create
method to run your business logic before the built-in create method runs.
See Overriding-Services document to understand how you can override the Create
method.
I tried to imlement this and it works.
Put the below class in your *.Application
project.
MyIdentityUserAppService.cs
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity;
using Volo.Abp.Validation;
using System;
using System.Linq;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using Volo.Abp;
using Volo.Saas.Editions;
using Volo.Saas.Tenants;
namespace AbpCommercialTest
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IIdentityUserAppService), typeof(IdentityUserAppService), typeof(MyIdentityUserAppService))]
public class MyIdentityUserAppService : IdentityUserAppService
{
private readonly ITenantRepository _tenantRepository;
private readonly IEditionRepository _editionRepository;
private readonly IIdentityUserRepository _userRepository;
public MyIdentityUserAppService(
IdentityUserManager userManager,
IIdentityUserRepository userRepository,
IIdentityRoleRepository roleRepository,
IOrganizationUnitRepository organizationUnitRepository,
IIdentityClaimTypeRepository identityClaimTypeRepository,
IdentityTwoFactorManager identityTwoFactorManager,
IOptions<IdentityOptions> identityOptions,
ITenantRepository tenantRepository,
IEditionRepository editionRepository) : base(userManager,
userRepository,
roleRepository,
organizationUnitRepository,
identityClaimTypeRepository,
identityTwoFactorManager,
identityOptions
)
{
_userRepository = userRepository;
_tenantRepository = tenantRepository;
_editionRepository = editionRepository;
}
public override async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
{
if (CurrentTenant.Id.HasValue) //check that it's tenant
{
var currentTenant = await _tenantRepository.GetAsync(CurrentTenant.Id.Value); //get tenant
if (!currentTenant.EditionId.HasValue)
{
throw new BusinessException("You don't have an edition!");
}
var usersCount = await _userRepository.GetCountAsync(); //get current user count of the tenant
var editionOfTenant = await _editionRepository.GetAsync(currentTenant.EditionId.Value);
editionOfTenant.ExtraProperties["MaxUserCount"] = 5; //temporary code for testing.
if (long.Parse(editionOfTenant.ExtraProperties["MaxUserCount"].ToString() ?? "0") > usersCount)
{
throw new UserFriendlyException("You do not have the right to create a new user!");
}
}
return await base.CreateAsync(input); //let the the built-in create method continue...
}
}
}
Note that I've used the extra properties of the edition. There are various ways to do this. Feaures or adding a new field to Tenant entitiy. Or creating a new entity etc...
Yeah this is a feature that exists in ASP.NET Zero. Be aware that the template comes with a few entities comparing the ones you will create. The main user data will be your business data and we need to figure out how to integrate your custom entity to be included in this schedule.
I reported this as a feature request under our internal repo with #5345
Ok. I created an issue for this. But adding description to the EntityDto is unnecessary and data duplication.
I guess you hit this issue https://github.com/dotnet/runtime/issues/1720
if you send us your customized classes we'll try to reproduce
ensure that https://localhost:44325 is accessible. sometimes Visual Studio kills the IIS Express
check out https://docs.abp.io/en/abp/latest/Background-Workers-Quartz
@prasad.gore do you see a valid response from https://localhost:44325/api/abp/application-configuration
to implement this you can add a new property to your tenant entity like TenantType
and you can overwrite the tenant creation method so that you force your logic before the creation. You check the tenant type and decide if the current user (or role) can operate on this.
this is a broad implementation. better to filter down your problem into smaller ones so I can write specific solutions.