Starts in:
0 DAY
11 HRS
14 MIN
7 SEC
Starts in:
0 D
11 H
14 M
7 S

Activities of "EngincanV"

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.

  • You can implement something similar with the following code.
public async override Task AddToOrganizationUnitAsync(IdentityUser user, OrganizationUnit ou)
{
    if (user.OrganizationUnits.Any())
    {
        return;
    }
    
    base.AddToOrganizationUnitAsync(user, ou);
}
  • To overriding IdentityUserManager, see https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services#example-overriding-a-domain-service.
  1. Yes, I have these lines of code in DBContext.
  2. 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.
  3. 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

we need to display like this

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).

  • You can use the Alerts to show errors on UI.
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).

Answer

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".

  • It will return a string array like => ["Role1", "Role2"] (not as stringified. So you can be able to query it.)

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"]' .

  • Yes you are right. I've used .Any instead of .All method of Linq in the previous answer, sorry for the misunderstanding. You can use the following code-snippet.
  • If the current user has one role but you want to check it has multiple roles, isn't it the expected behaviour to return false?
public static class CurrentUserExtensions
{
    public static bool IsInSpecifiedRoles(this ICurrentUser currentUser, string[] roles)
    {
        var userRoles = currentUser.Roles;
        return userRoles.All(userRole => roles.Contains(userRole));
    }
} 
  • If you want to check for just one role use the 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.

Hi @Spospisil, you need to override LogoReverseUrl in YourProjectBrandingProvider on your *.Web layer.

[Dependency(ReplaceServices = true)]
public class YourProjectBrandingProvider : DefaultBrandingProvider
{
  public override string AppName => "YourProjectName";

  public override string LogoReverseUrl => "/images/logo/abp-purple.png"; //override LogoReverseUrl
}

I've added an image under wwwroot/images/logo named abp-purple.png. And I've also cleared the cache to see the result.

There are some restrictions to implement impersonation for Blazor WASM.

Related issue: https://github.com/abpframework/abp/issues/9997

Showing 631 to 640 of 724 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06