I'm getting Http error 404 as a result on working on abp.io framework

Viewed 294

I'm new at working on the abp.io framework, precisely Angular + Entity Framework Core.

I want to be able to create or display an objects list of a class that I've created.

For example, I've made a class called Address on the Domain layer.

Here is its AppService on the Application layer:

namespace ASKOM.RefPlusStudio.core.Services
{
[Authorize(corePermissions.Addresses.Default)]
public class AddressAppService : coreAppService, IAddressAppService
{
    private readonly IAddressRepository _addressRepository;
    private readonly AddressManager _addressManager;

    public AddressAppService(IAddressRepository addressRepository, AddressManager addressManager)
    {
        _addressRepository = addressRepository;
        _addressManager = addressManager;
    }

    [Authorize(corePermissions.Addresses.Create)]
    public async Task<AddressDto> CreateAsync(CreateUpdateAddressDto input)
    {
        var address = await _addressManager.CreateAsync(
            input.StreetNumber,
            input.StreetName,
            input.PostalCode,
            input.City,
            input.Country
        );

        await _addressRepository.InsertAsync(address);

        return ObjectMapper.Map<Address, AddressDto>(address);
    }

    [Authorize(corePermissions.Addresses.Delete)]
    public async Task DeleteAsync(Guid id)
    {
        await _addressRepository.DeleteAsync(id);
    }

    public async Task<AddressDto> GetAsync(Guid id)
    {
        var address = await _addressRepository.GetAsync(id);
        return ObjectMapper.Map<Address, AddressDto>(address);
    }

    public async Task<PagedResultDto<AddressDto>> GetListAsync(GetAddressListDto input)
    {
        if (input.Sorting.IsNullOrWhiteSpace())
        {
            input.Sorting = nameof(Address.Country);
        }

        var addresses = await _addressRepository.GetListAsync(
            input.SkipCount,
            input.MaxResultCount,
            input.Sorting,
            input.Filter
        );

        var totalCount = await AsyncExecuter.CountAsync(
            _addressRepository.WhereIf(
                !input.Filter.IsNullOrWhiteSpace(),
                address => address.Country.Contains(input.Filter)
            )
        );

        return new PagedResultDto<AddressDto>(
            totalCount,
            ObjectMapper.Map<List<Address>, List<AddressDto>>(addresses)
        );
    }

    [Authorize(corePermissions.Addresses.Edit)]
    public async Task UpdateAsync(Guid id, CreateUpdateAddressDto input)
    {
        var address = await _addressRepository.GetAsync(id);
           
            address.StreetNumber = input.StreetNumber;
            address.StreetName = input.StreetName;
            address.PostalCode = input.PostalCode;
            address.City = input.City;
            address.Country = input.Country;

        await _addressRepository.UpdateAsync(address);
    }
 }
 } 

I gave them all the permissions needed.

Here is corePermissions.cs :

namespace ASKOM.RefPlusStudio.core.Permissions
{
public static class corePermissions
{
    public const string GroupName = "core";

    //Add your own permission names. Example:
    //public const string MyPermission1 = GroupName + ".MyPermission1";

    public static class Addresses
    {
        public const string Default = GroupName + ".Addresses";
        public const string Create = Default + ".Create";
        public const string Edit = Default + ".Edit";
        public const string Delete = Default + ".Delete";
    }
}
}

I wanted to see if it can display an Addresses list so I've made a static one on DataSeeder:

namespace ASKOM.RefPlusStudio.core
{
public class coreDataSeederContributor : IDataSeedContributor, ITransientDependency
{
    private readonly IRepository<Address, Guid> _addressRepository;
    private readonly IGuidGenerator _guidGenerator;

    public coreDataSeederContributor(IRepository<Address, Guid> addressRepository, IGuidGenerator guidGenerator)
    {
        _addressRepository = addressRepository;
        _guidGenerator = guidGenerator;
    }

    public async Task SeedAsync(DataSeedContext context)
    {
        if (await _addressRepository.GetCountAsync() > 0)
        {
            return;
        }
        var address = new Address(

                id: _guidGenerator.Create(),
                streetNumber: 07,
                streetName: "Med Salah Belhaj",
                postalCode: 2080,
                city: "Ariana",
                country: "Tunisie"
            );
            //autoSave: true
        
        await _addressRepository.InsertAsync(address);
    }
}
}

Here is now the result on Swagger UI:

get-address-swagger

When I try to open the request URL, here is what it shows:

error-404-access-denied

I'm sure that I may have forgotten something and that's why I get Access Denied on the Request URL, but I don't really know what it is because I'm new at this.

Could you please help me? Thank you

1 Answers

There was a problem with the database. That's why it hasn't read the data I've provided in the DataSeedProvider.

Related