Activities of "mel@quadsoftpa.com"

Thank you for your response. I actually just switched to that. I'd rather be able to call it separately, but this will work.

my goal was to get a List<ValidationResult>. but I'm hoping the following will work instead

            var exceptions = new List<Exception>();
            var isIdUnique = await IsCodeUnique(dto.Id, dto.Code);

            if (!isIdUnique)
            {
                exceptions.Add(new UserFriendlyException("Country Code already exists"));
            }

            var isNameUnique = await IsNameUnique(dto.Id, dto.Name);

            if (!isNameUnique)
            {
                exceptions.Add(new UserFriendlyException("Country Name already exists"));
            }

            if (exceptions.Any())
            {
                throw new AggregateException(exceptions);
            }

I don't want to have to duplicate every base crud like create below just to do validation. There's got to be a better way. Please advise.

    public virtual async Task&lt;TGetOutputDto&gt; CreateAsync(TCreateInput input)
    {
        await CheckCreatePolicyAsync();

*** VALIDATE***

        var entity = await MapToEntityAsync(input);

        TryToSetTenantId(entity);

        await Repository.InsertAsync(entity, autoSave: true);

        return await MapToGetOutputDtoAsync(entity);
    }

I find that hard to believe that the only methods you can call our the base CRUD. Certainly you should be able to add a permission and be able to call a custom method in the Application Service.

Without this flexibility, that means having repetitive code many many times. I want to use the base CRUD but validate. This should be very very basic.

I reverted back to my original implementation which does the validation in the application service. However I still need my second question answered because I have the same issue.

when calling the service from the web project I can successfully use Service.UpdateAsync but Service.ValidateAsync needs permissions. How do I configure a proper permission?

  • ABP Framework version: 4RC
  • UI type: MVC
  • Tiered (MVC) or Identity Server Seperated (Angular): no

I really don't like doing this validation in the DTO, but I was unable to get it to work any other way. It would be great if the second half of your validation page (https://docs.abp.io/en/abp/latest/Validation) had more detail and specific usage on an alternative method.

Regardless, I'm dealing with a few issues with this approach:

  • there really should be a ValidateAsync(ValidationContext validationContext) method
  • when calling the service (IsIdUnique for example) I'm getting
    probably a simple fix, but the only way I found around it is removing authorization from the service which is obviously not a real fix.

Thanks

  public class CountryCreateDto : IValidatableObject
    {
        private string _id;

        private string _name;

        [Required]
        [StringLength(CountryConsts.IdMaxLength, MinimumLength = CountryConsts.IdMinLength)]
        [RegularExpression(@"^[A-Z''-'\s]{2,3}$", ErrorMessage = "The Country Code must be between two and three uppercase letters.")]
        [DisplayName("Code")]
        public string Id
        {
            get => _id;
            set => _id = value.Trim()
                              .ToUpper();
        }

        [Required]
        [StringLength(CountryConsts.NameMaxLength, MinimumLength = CountryConsts.NameMinLength)]
        public string Name
        {
            get => _name;
            set => _name = value.Trim().ToUpper();
        }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            var service = validationContext.GetRequiredService<ICountryAppService>();

            var validationResults = new List<ValidationResult>();

            var isIdUnique = Task.Run(async () => await service.IsIdUnique(Id))
                                 .Result;

            if (!isIdUnique)
            {
                validationResults.Add(new ValidationResult("Country Code already exists", new[]
                {
                    "Id"
                }));
            }

            var isNameUnique = Task.Run(async () => await service.IsNameUnique( Name))
                                   .Result;

            if (!isNameUnique)
            {
                validationResults.Add(new ValidationResult("Country Name already exists", new[]
                {
                    "Name"
                }));
            }

            return validationResults;
        }
    }

Switching

public class CountryAppService : ApplicationService, ICountryAppService

to

    public class CountryAppService : CrudAppService<Country,CountryDto, string, GetCountriesInput, CountryCreateDto, CountryUpdateDto>, ICountryAppService

resolved the issue

. .sending linkk with code to shiwei.liang@volosoft.com

I have a project for you to review this. Please provide an email address .

  • **ABP Framework version: 4.0.0-rc.3
  • UI type: MVC
  • Tiered (MVC) or Identity Server Seperated (Angular): no
  • Exception message and stack trace:

I am having all sorts of trouble with this error. Sometimes it works once, sometimes not at all

This is coming from an ABP Suite generated ApplicationService

public class CountryAppService : ApplicationService, ICountryAppService

This is being utilized by a Blazor component hosted in a razor file

<app>
    <component type="typeof(CountryManager)" render-mode="ServerPrerendered" />
</app>

I had no problems whatsoever with v3.

Let me know if you require additional information. Thank you

my only outstanding issue is

thank you

Showing 31 to 40 of 50 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on January 14, 2025, 14:54