Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "aaron"

In any case, don't construct paths like that. Try this:

private IConfigurationRoot BuildConfig()
{
    var currentPath = Directory.GetCurrentDirectory();

    var config = new ConfigurationBuilder()
        .SetBasePath(typeof(MyProjectWebHostModule).GetAssembly().GetDirectoryPathOrNull())
        .AddJsonFile("appsettings.json");

    config
        .SetBasePath(currentPath)
        .AddJsonFile("testingappsettings.json");

    return config.Build();
}

Then explain this line:

.AddJsonFile(Path.Combine(currentPath, "..", "..", "..", "..", "..", "src", "MyCompany.MyProject.Web.Host", $"appsettings.json"), false);

Doesn't your Test project have an appsettings.json with the license code?

Which file is not read?

Which folder is testingappsettings.json located in?

A helper like this can be implemented as an extension:

namespace AbpCompanyName.AbpProjectName.Domain.Repositories
{
    public static class RepositoryExtensions
    {
        public static Task<TEntity> UpdateOwnAsync<TEntity, TPrimaryKey>(this IRepository<TEntity, TPrimaryKey> repository, TEntity entity)
            where TEntity : class, IEntity<TPrimaryKey>, ICreationAudited
        {
            var currentUserId = SingletonDependency<IAbpSession>.Instance.UserId;
            if (currentUserId != entity.CreatorUserId)
            {
                return null; // Or throw exception
            }

            return repository.UpdateAsync(entity);
        }
    }
}

Usage:

// using AbpCompanyName.AbpProjectName.Domain.Repositories

_repository.UpdateOwnAsync(entity);

That should be sufficient for you to modify it yourself if you want to:

  • pass in "Own" as a parameter instead of the method name, or
  • use it with updateAction.
Answer

Where is your seed method called?

Answer

You can run Add-Migration "Execute_Seed" to create an empty migration.

Remove .First() — you may get an "error" from Intellisense, but it should still compile. See discussion (aspnet/EntityFrameworkCore#6560) and cause (dotnet/roslyn#8237).

From the documentation on Handling Base Events:

you can implement IEventHandler<EventData> to handle all events in the application.

Showing 1141 to 1150 of 1543 entries