Hi @LawrenceKwan, can you check the Redis is running or not? If it is not running please first run it and then run the three project again.
https://docs.abp.io/en/abp/latest/Startup-Templates/Application#pre-requirements
Hi @MILLENNIUM, you can check the Plug-In Modules documentation, i think this is what you are asking for.
And Is it possible to add entities dynamicly in runtime ?
There is an open source project named Abp.DynamicEntity, maybe you can use it to create entities dynamically on runtime.
Hi @bozkan, you can override the AddToOrganizationUnitAsync method of IdentityUserManager
class and inside of the method simply check the user is in any organization unit or not.
public async override Task AddToOrganizationUnitAsync(IdentityUser user, OrganizationUnit ou)
{
if (user.OrganizationUnits.Any())
{
return;
}
base.AddToOrganizationUnitAsync(user, ou);
}
IdentityUserManager
, see https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services#example-overriding-a-domain-service.
- Yes, I have these lines of code in DBContext.
- I have used IdentityUser and IIdentityUserRepository to gather data for Users and OrganizationUnit with these I want to join based on condition my userdefined two entities.
- I have constructed a class where I have called IIdentityUserRepository, IdentityUser objects using Get method.
Anything I need to change here.
Hi @radhikashrotre, sorry for the late response. Can you share the relevant method that you've tried to join the entities?
Hi @Shoba24, you also need to add return Page();
line after the Alerts.Danger(ex.Message);
to show the error in your UI.
public async Task <IActionResult> OnPostAsync()
{
try
{
//your code
}
catch(Exception ex)
{
Alerts.Danger(ex.Message);
return Page(); //show alert on the page
}
return Redirect("/PurchaseOrders");
}
For other alert types see https://docs.abp.io/en/abp/4.4/UI/AspNetCore/Page-Alerts#alert-types
Hi, sorry for the misunderstanding but you can not trigger a modal like in the above photo. (if you want to trigger it, you need to call the method that throws an exception on the js side).
public async Task <IActionResult> OnPostAsync()
{
try
{
//your code
}
catch(Exception ex)
{
Alerts.Danger(ex.Message); //for other alert types see https://docs.abp.io/en/abp/4.4/UI/AspNetCore/Page-Alerts#alert-types
}
return Redirect("/PurchaseOrders");
}
Hi, can you share the OnPost method of your CreateModal.cshtml file?
Hi @Shoba24, I think you need to use the UserFriendlyException
(https://docs.abp.io/en/abp/4.4/Exception-Handling#user-friendly-exception).
Hi @kresimirm,
If my current user is in two roles "Role1" and "Role2" currentUser.Roles will return string[] that contains one record with stringified '["Role1","Role2"]' so I will have to split or deserialize that string to check if user is in "Role1".
Furthermore, if user is just in one role currentUser.Roles will retrurn "RoleName" as simple string record so your code wont work again becasue it will compare "Role1" with '["Role1","Role2"]' .
.Any
instead of .All
method of Linq in the previous answer, sorry for the misunderstanding. You can use the following code-snippet.public static class CurrentUserExtensions
{
public static bool IsInSpecifiedRoles(this ICurrentUser currentUser, string[] roles)
{
var userRoles = currentUser.Roles;
return userRoles.All(userRole => roles.Contains(userRole));
}
}
IsInRole
method of ICurrentUser
, Otherwise you can use the above code-snippet to check the current user has the all roles that you've specified or not. Or you can implement your own logic for other use-cases.Hi @Neozzz, I will send you the steps to be done via email as soon as possible. If the last changes resolved your problem you can close this question. I will inform you via email.