diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index b284bcf..bb7d144 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,7 +1,7 @@ name: Build and run unit tests env: - DOTNET_VERSION: '8.x' + DOTNET_VERSION: '9.x' on: push: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 60e1868..efff0aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: Release CI/CD env: AZURE_WEBAPP_NAME: app-open5etools AZURE_WEBAPP_PACKAGE_PATH: '.' - DOTNET_VERSION: '8.x' + DOTNET_VERSION: '9.x' on: push: diff --git a/.vscode/launch.json b/.vscode/launch.json index ce43488..57fa3ea 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Open5ETools.Web/bin/Debug/net8.0/Open5ETools.Web.dll", + "program": "${workspaceFolder}/src/Open5ETools.Web/bin/Debug/net9.0/Open5ETools.Web.dll", "args": [], "cwd": "${workspaceFolder}/src/Open5ETools.Web", "stopAtEntry": false, diff --git a/Directory.Packages.props b/Directory.Packages.props index bf99356..bacb0cd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,30 +3,30 @@ true - + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - + + \ No newline at end of file diff --git a/README.md b/README.md index b4d830a..9bd0814 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This repo is for playing around with DnD5E SRD materials, trying out some techno ## Prerequisites -You have .NET 8 SDK installed. +You have .NET 9 SDK installed. ## Get the code diff --git a/src/Open5ETools.Core/Common/Interfaces/Services/DM/IDungeonService.cs b/src/Open5ETools.Core/Common/Interfaces/Services/DM/IDungeonService.cs index faf0822..ec65b23 100644 --- a/src/Open5ETools.Core/Common/Interfaces/Services/DM/IDungeonService.cs +++ b/src/Open5ETools.Core/Common/Interfaces/Services/DM/IDungeonService.cs @@ -7,7 +7,7 @@ public interface IDungeonService Task> GetAllDungeonOptionsAsync(CancellationToken cancellationToken); Task> GetAllDungeonOptionsForUserAsync(int userId, CancellationToken cancellationToken); Task GetDungeonOptionAsync(int id, CancellationToken cancellationToken); - Task GetDungeonOptionByNameAsync(string dungeonName, int userId, CancellationToken cancellationToken); + Task GetDungeonOptionByNameAsync(string dungeonName, int userId, CancellationToken cancellationToken); Task GetDungeonAsync(int id, CancellationToken cancellationToken); Task CreateOrUpdateDungeonAsync(DungeonOptionModel optionModel, bool addDungeon, int level, CancellationToken cancellationToken); Task UpdateDungeonAsync(DungeonModel model, CancellationToken cancellationToken); @@ -19,4 +19,5 @@ public interface IDungeonService Task DeleteDungeonAsync(int id, CancellationToken cancellationToken); Task GenerateDungeonAsync(DungeonOptionModel model); Task RenameDungeonAsync(int optionId, int userId, string newName, CancellationToken cancellationToken); + Task ExportToJsonAsync(int dungeonId, CancellationToken cancellationToken); } \ No newline at end of file diff --git a/src/Open5ETools.Core/ConfigureServices.cs b/src/Open5ETools.Core/ConfigureServices.cs index ccfa4a2..2a4dfba 100644 --- a/src/Open5ETools.Core/ConfigureServices.cs +++ b/src/Open5ETools.Core/ConfigureServices.cs @@ -6,12 +6,14 @@ using Open5ETools.Core.Common.Interfaces.Services.EG; using Open5ETools.Core.Common.Interfaces.Services.SM; using Open5ETools.Core.Services; +using Open5ETools.Core.Services.Automapper; using Open5ETools.Core.Services.DM; using Open5ETools.Core.Services.DM.Generator; using Open5ETools.Core.Services.EG; using Open5ETools.Core.Services.SM; namespace Open5ETools.Core; + public static class ConfigureServices { public static IServiceCollection AddApplicationServices( @@ -29,11 +31,7 @@ this IServiceCollection services .AddScoped() .AddScoped(); - services.AddAutoMapper(cfg => - { - cfg.AllowNullCollections = true; - } - , AppDomain.CurrentDomain.GetAssemblies()); + services.AddAutoMapper(cfg => { cfg.AllowNullCollections = true; }, typeof(UserProfile)); return services; } diff --git a/src/Open5ETools.Core/Open5ETools.Core.csproj b/src/Open5ETools.Core/Open5ETools.Core.csproj index 638ab14..f4784be 100644 --- a/src/Open5ETools.Core/Open5ETools.Core.csproj +++ b/src/Open5ETools.Core/Open5ETools.Core.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable diff --git a/src/Open5ETools.Core/Services/DM/DungeonService.cs b/src/Open5ETools.Core/Services/DM/DungeonService.cs index 022cfb0..a3601fe 100644 --- a/src/Open5ETools.Core/Services/DM/DungeonService.cs +++ b/src/Open5ETools.Core/Services/DM/DungeonService.cs @@ -1,4 +1,5 @@ -using AutoMapper; +using System.Text.Json; +using AutoMapper; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Open5ETools.Core.Common.Exceptions; @@ -11,7 +12,8 @@ namespace Open5ETools.Core.Services.DM; -public class DungeonService(IMapper mapper, +public class DungeonService( + IMapper mapper, IAppDbContext context, IDungeon dungeon, IDungeonNoCorridor dungeonNcDungeon, @@ -23,7 +25,8 @@ public class DungeonService(IMapper mapper, private readonly IMapper _mapper = mapper; private readonly ILogger _logger = logger; - public async Task CreateDungeonOptionAsync(DungeonOptionModel dungeonOption, CancellationToken cancellationToken) + public async Task CreateDungeonOptionAsync(DungeonOptionModel dungeonOption, + CancellationToken cancellationToken) { try { @@ -67,7 +70,8 @@ public async Task AddDungeonAsync(DungeonModel savedDungeon, CancellationTo } } - public async Task CreateOrUpdateDungeonAsync(DungeonOptionModel optionModel, bool addDungeon, int level, CancellationToken cancellationToken) + public async Task CreateOrUpdateDungeonAsync(DungeonOptionModel optionModel, bool addDungeon, + int level, CancellationToken cancellationToken) { try { @@ -77,18 +81,21 @@ public async Task CreateOrUpdateDungeonAsync(DungeonOptionModel op return await AddDungeonToExistingOptionAsync(optionModel, level, cancellationToken); } - var existingDungeonOption = await GetDungeonOptionByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken); + var existingDungeonOption = + await GetDungeonOptionByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken); if (existingDungeonOption is null) { return await CreateOptionAndAddDungeonToItAsync(optionModel, cancellationToken); } // regenerate - var existingDungeons = await ListUserDungeonsByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken); + var existingDungeons = + await ListUserDungeonsByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken); var oldDungeon = existingDungeons.FirstOrDefault(); if (oldDungeon is not null) { - return await UpdateExistingDungeonAsync(optionModel, existingDungeonOption, oldDungeon, cancellationToken); + return await UpdateExistingDungeonAsync(optionModel, existingDungeonOption, oldDungeon, + cancellationToken); } optionModel.Id = existingDungeonOption.Id; @@ -101,7 +108,8 @@ public async Task CreateOrUpdateDungeonAsync(DungeonOptionModel op } } - private async Task UpdateExistingDungeonAsync(DungeonOptionModel optionModel, DungeonOptionModel existingDungeonOption, DungeonModel oldDungeon, CancellationToken cancellationToken) + private async Task UpdateExistingDungeonAsync(DungeonOptionModel optionModel, + DungeonOptionModel existingDungeonOption, DungeonModel oldDungeon, CancellationToken cancellationToken) { var dungeonModel = await GenerateDungeonAsync(optionModel, existingDungeonOption.Id); dungeonModel.Id = oldDungeon.Id; @@ -110,20 +118,23 @@ private async Task UpdateExistingDungeonAsync(DungeonOptionModel o return dungeonModel; } - private async Task CreateOptionAndAddDungeonToItAsync(DungeonOptionModel optionModel, CancellationToken cancellationToken) + private async Task CreateOptionAndAddDungeonToItAsync(DungeonOptionModel optionModel, + CancellationToken cancellationToken) { - await CreateDungeonOptionAsync(optionModel, cancellationToken); - var created = await GetDungeonOptionByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken); - var dungeonModel = await GenerateDungeonAsync(optionModel, created.Id); + var dungeonOptionId = await CreateDungeonOptionAsync(optionModel, cancellationToken); + var dungeonModel = await GenerateDungeonAsync(optionModel, dungeonOptionId); dungeonModel.Level = 1; var id = await AddDungeonAsync(dungeonModel, cancellationToken); dungeonModel.Id = id; return dungeonModel; } - private async Task AddDungeonToExistingOptionAsync(DungeonOptionModel optionModel, int level, CancellationToken cancellationToken) + private async Task AddDungeonToExistingOptionAsync(DungeonOptionModel optionModel, int level, + CancellationToken cancellationToken) { - var existingDungeons = (await ListUserDungeonsByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken)).ToList(); + var existingDungeons = + (await ListUserDungeonsByNameAsync(optionModel.DungeonName, optionModel.UserId, cancellationToken)) + .ToList(); var dungeonModel = await GenerateDungeonAsync(optionModel, optionModel.Id); dungeonModel.Level = level; if (existingDungeons.Exists(d => d.Level == level)) @@ -135,6 +146,7 @@ private async Task AddDungeonToExistingOptionAsync(DungeonOptionMo { dungeonModel.Id = await AddDungeonAsync(dungeonModel, cancellationToken); } + return dungeonModel; } @@ -166,10 +178,10 @@ public async Task> GetAllDungeonOptionsAsync(Can try { var options = await _context.DungeonOptions - .Include(d => d.Dungeons) - .AsNoTracking() - .OrderBy(d => d.Created) - .ToListAsync(cancellationToken); + .Include(d => d.Dungeons) + .AsNoTracking() + .OrderBy(d => d.Created) + .ToListAsync(cancellationToken); return options.Select(_mapper.Map); } @@ -180,16 +192,17 @@ public async Task> GetAllDungeonOptionsAsync(Can } } - public async Task> GetAllDungeonOptionsForUserAsync(int userId, CancellationToken cancellationToken) + public async Task> GetAllDungeonOptionsForUserAsync(int userId, + CancellationToken cancellationToken) { try { var options = await _context.DungeonOptions - .AsNoTracking() - .Include(d => d.Dungeons) - .Where(d => d.UserId == userId) - .OrderBy(d => d.Created) - .ToListAsync(cancellationToken); + .AsNoTracking() + .Include(d => d.Dungeons) + .Where(d => d.UserId == userId) + .OrderBy(d => d.Created) + .ToListAsync(cancellationToken); return options.Select(_mapper.Map); } @@ -200,15 +213,16 @@ public async Task> GetAllDungeonOptionsForUserAs } } - public async Task GetDungeonOptionByNameAsync(string dungeonName, int userId, CancellationToken cancellationToken) + public async Task GetDungeonOptionByNameAsync(string dungeonName, int userId, + CancellationToken cancellationToken) { try { return _mapper.Map(await _context.DungeonOptions - .Include(d => d.Dungeons) - .AsNoTracking() - .Where(d => d.DungeonName.Equals(dungeonName) && d.UserId == userId) - .FirstOrDefaultAsync(cancellationToken)); + .Include(d => d.Dungeons) + .AsNoTracking() + .Where(d => d.DungeonName.Equals(dungeonName) && d.UserId == userId) + .FirstOrDefaultAsync(cancellationToken)); } catch (Exception ex) { @@ -226,7 +240,8 @@ public async Task DeleteDungeonOptionAsync(int id, CancellationToken cance if (entity is not null) { - var dungeons = await _context.Dungeons.Where(sd => sd.DungeonOptionId == entity.Id).ToListAsync(cancellationToken); + var dungeons = await _context.Dungeons.Where(sd => sd.DungeonOptionId == entity.Id) + .ToListAsync(cancellationToken); _context.Dungeons.RemoveRange(dungeons); _context.DungeonOptions.Remove(entity); await _context.SaveChangesAsync(cancellationToken); @@ -285,12 +300,12 @@ public async Task> ListUserDungeonsAsync(int userId, C try { var result = await _context.DungeonOptions - .AsNoTracking() - .Include(d => d.Dungeons) - .Where(d => d.UserId == userId) - .OrderBy(d => d.Created) - .SelectMany(d => d.Dungeons) - .ToListAsync(cancellationToken); + .AsNoTracking() + .Include(d => d.Dungeons) + .Where(d => d.UserId == userId) + .OrderBy(d => d.Created) + .SelectMany(d => d.Dungeons) + .ToListAsync(cancellationToken); return result.Select(_mapper.Map); } catch (Exception ex) @@ -300,17 +315,18 @@ public async Task> ListUserDungeonsAsync(int userId, C } } - public async Task> ListUserDungeonsByNameAsync(string dungeonName, int userId, CancellationToken cancellationToken) + public async Task> ListUserDungeonsByNameAsync(string dungeonName, int userId, + CancellationToken cancellationToken) { try { var result = await _context.DungeonOptions - .AsNoTracking() - .Include(d => d.Dungeons) - .Where(d => d.DungeonName.Equals(dungeonName) && d.UserId == userId) - .OrderBy(d => d.Created) - .SelectMany(d => d.Dungeons) - .ToListAsync(cancellationToken); + .AsNoTracking() + .Include(d => d.Dungeons) + .Where(d => d.DungeonName.Equals(dungeonName) && d.UserId == userId) + .OrderBy(d => d.Created) + .SelectMany(d => d.Dungeons) + .ToListAsync(cancellationToken); return result.Select(_mapper.Map); } catch (Exception ex) @@ -325,8 +341,8 @@ public async Task GetDungeonAsync(int id, CancellationToken cancel try { return _mapper.Map(await _context.Dungeons - .AsNoTracking() - .FirstOrDefaultAsync(d => d.Id == id, cancellationToken)); + .AsNoTracking() + .FirstOrDefaultAsync(d => d.Id == id, cancellationToken)); } catch (Exception ex) { @@ -340,7 +356,7 @@ public async Task UpdateDungeonAsync(DungeonModel model, CancellationToken cance try { var entity = await _context.Dungeons - .FirstOrDefaultAsync(d => d.Id == model.Id, cancellationToken); + .FirstOrDefaultAsync(d => d.Id == model.Id, cancellationToken); if (entity is not null) { _mapper.Map(model, entity); @@ -358,7 +374,8 @@ public async Task GetDungeonOptionAsync(int id, Cancellation { try { - return _mapper.Map(await _context.DungeonOptions.FirstOrDefaultAsync(d => d.Id == id, cancellationToken)); + return _mapper.Map( + await _context.DungeonOptions.FirstOrDefaultAsync(d => d.Id == id, cancellationToken)); } catch (Exception ex) { @@ -371,7 +388,8 @@ public async Task RenameDungeonAsync(int optionId, int userId, string newName, C { try { - var entity = await _context.DungeonOptions.FirstOrDefaultAsync(d => d.Id == optionId && d.UserId == userId, cancellationToken); + var entity = await _context.DungeonOptions.FirstOrDefaultAsync(d => d.Id == optionId && d.UserId == userId, + cancellationToken); if (entity is not null) { entity.DungeonName = newName; @@ -380,7 +398,24 @@ public async Task RenameDungeonAsync(int optionId, int userId, string newName, C } catch (Exception ex) { - _logger.LogError(ex, "Update dungeon failed."); + _logger.LogError(ex, "Rename dungeon failed."); + throw; + } + } + + public async Task ExportToJsonAsync(int dungeonId, CancellationToken cancellationToken) + { + try + { + var dungeon = _mapper.Map(await _context.Dungeons + .AsNoTracking() + .FirstOrDefaultAsync(d => d.Id == dungeonId, cancellationToken)); + + return dungeon is not null ? JsonSerializer.Serialize(dungeon) : string.Empty; + } + catch (Exception ex) + { + _logger.LogError(ex, "ExportToJson failed."); throw; } } diff --git a/src/Open5ETools.Infrastructure/ConfigureServices.cs b/src/Open5ETools.Infrastructure/ConfigureServices.cs index f91489a..60d045a 100644 --- a/src/Open5ETools.Infrastructure/ConfigureServices.cs +++ b/src/Open5ETools.Infrastructure/ConfigureServices.cs @@ -10,6 +10,7 @@ using System.Reflection; namespace Open5ETools.Infrastructure; + public static class ConfigureServices { public static IServiceCollection AddInfrastructureServices( @@ -22,10 +23,11 @@ public static IServiceCollection AddInfrastructureServices( services.AddDbContext((sp, options) => { options.UseSqlServer(configuration.GetConnectionString(AppDbContext.Open5ETools), - sqlServerOptionsAction: sqlOptions => - { - sqlOptions.MigrationsAssembly(typeof(SqlServerContext).GetTypeInfo().Assembly.GetName().Name); - }) + sqlServerOptionsAction: sqlOptions => + { + sqlOptions.MigrationsAssembly(typeof(SqlServerContext).GetTypeInfo().Assembly.GetName() + .Name); + }) .AddInterceptors( ActivatorUtilities.CreateInstance(sp)); }); @@ -40,10 +42,11 @@ public static IServiceCollection AddInfrastructureServices( services.AddDbContext((sp, options) => { options.UseSqlite(connString?.Replace(SqliteContext.HomeToken, home), - sqliteOptionsAction: sqlOptions => - { - sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName().Name); - }) + sqliteOptionsAction: sqlOptions => + { + sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName() + .Name); + }) .AddInterceptors( ActivatorUtilities.CreateInstance(sp)); }); @@ -54,7 +57,8 @@ public static IServiceCollection AddInfrastructureServices( break; default: throw new ServiceException( - string.Format(Resources.Error.DbProviderError, configuration.GetConnectionString(AppDbContext.DbProvider))); + string.Format(Resources.Error.DbProviderError, + configuration.GetConnectionString(AppDbContext.DbProvider))); } AddOptions(services, configuration); @@ -65,9 +69,9 @@ public static IServiceCollection AddInfrastructureServices( private static void AddOptions(IServiceCollection services, IConfiguration configuration) { services.AddOptions() - .Bind(configuration.GetSection(AppConfigOptions.AppConfig)) - .ValidateDataAnnotations() - .ValidateOnStart(); + .Bind(configuration.GetSection(AppConfigOptions.AppConfig)) + .ValidateDataAnnotations() + .ValidateOnStart(); } public static IServiceCollection AddTestInfrastructureServices(this IServiceCollection services, @@ -77,10 +81,10 @@ public static IServiceCollection AddTestInfrastructureServices(this IServiceColl services.AddDbContext((sp, options) => { options.UseSqlite(connection, - sqliteOptionsAction: sqlOptions => - { - sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName().Name); - }) + sqliteOptionsAction: sqlOptions => + { + sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName().Name); + }) .AddInterceptors(ActivatorUtilities.CreateInstance(sp)); }); services.AddScoped(sp => diff --git a/src/Open5ETools.Infrastructure/Data/AppDbContextInitializer.cs b/src/Open5ETools.Infrastructure/Data/AppDbContextInitializer.cs index f45c318..7378d10 100644 --- a/src/Open5ETools.Infrastructure/Data/AppDbContextInitializer.cs +++ b/src/Open5ETools.Infrastructure/Data/AppDbContextInitializer.cs @@ -16,6 +16,7 @@ using Spell = Open5ETools.Core.Common.Models.Json.Spell; namespace Open5ETools.Infrastructure.Data; + public class AppDbContextInitializer( IMapper mapper, IAppDbContext context, @@ -37,6 +38,7 @@ public async Task UpdateAsync(CancellationToken cancellationToken) await _context.Database.EnsureCreatedAsync(cancellationToken); } } + public async Task SeedDataAsync(CancellationToken cancellationToken) { if (!_context.Users.Any()) @@ -67,11 +69,7 @@ public async Task SeedTestBaseAsync(CancellationToken cancellationToken) private async Task SeedSpellsAsync(CancellationToken cancellationToken) { var spells = JsonHelper.DeserializeJson(JsonHelper.SpellFileName); - var spellEntities = new List(); - foreach (var spell in spells) - { - spellEntities.Add(_mapper.Map(spell)); - } + var spellEntities = spells.Select(spell => _mapper.Map(spell)).ToList(); await _context.Spells.AddRangeAsync(spellEntities, cancellationToken); await _context.SaveChangesAsync(cancellationToken); @@ -80,14 +78,7 @@ private async Task SeedSpellsAsync(CancellationToken cancellationToken) private async Task SeedTreasuresAsync(CancellationToken cancellationToken) { var treasures = JsonHelper.DeserializeJson(JsonHelper.TreasureFileName); - var treasureEntities = new List(); - foreach (var treasure in treasures) - { - treasureEntities.Add(new Treasure - { - TreasureDescription = treasure - }); - } + var treasureEntities = treasures.Select(treasure => new Treasure { TreasureDescription = treasure }).ToList(); await _context.Treasures.AddRangeAsync(treasureEntities, cancellationToken); await _context.SaveChangesAsync(cancellationToken); @@ -96,16 +87,9 @@ private async Task SeedTreasuresAsync(CancellationToken cancellationToken) private async Task SeedMonstersAsync(CancellationToken cancellationToken) { var monsters = JsonHelper.DeserializeJson(JsonHelper.MonsterFileName); - var monsterEntites = new List(); - foreach (var monster in monsters) - { - monsterEntites.Add(new Core.Domain.EG.Monster - { - JsonMonster = monster - }); - } + var monsterEntities = monsters.Select(monster => new Core.Domain.EG.Monster { JsonMonster = monster }).ToList(); - await _context.Monsters.AddRangeAsync(monsterEntites, cancellationToken); + await _context.Monsters.AddRangeAsync(monsterEntities, cancellationToken); await _context.SaveChangesAsync(cancellationToken); } @@ -409,7 +393,7 @@ private async Task SeedTreasureValueAsync(CancellationToken token) new() { Key = OptionKey.TreasureValue, - Name = Resources.Common.Standard, + Name = Resources.Common.Standard, Value = "1" }, new() diff --git a/src/Open5ETools.Infrastructure/Open5ETools.Infrastructure.csproj b/src/Open5ETools.Infrastructure/Open5ETools.Infrastructure.csproj index f9d9ca0..4ec0c90 100644 --- a/src/Open5ETools.Infrastructure/Open5ETools.Infrastructure.csproj +++ b/src/Open5ETools.Infrastructure/Open5ETools.Infrastructure.csproj @@ -1,22 +1,16 @@  - net8.0 + net9.0 enable enable - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Open5ETools.Resources/Open5ETools.Resources.csproj b/src/Open5ETools.Resources/Open5ETools.Resources.csproj index bbccf35..93287b3 100644 --- a/src/Open5ETools.Resources/Open5ETools.Resources.csproj +++ b/src/Open5ETools.Resources/Open5ETools.Resources.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable diff --git a/src/Open5ETools.Web/ConfigureServices.cs b/src/Open5ETools.Web/ConfigureServices.cs index a5b7287..b198782 100644 --- a/src/Open5ETools.Web/ConfigureServices.cs +++ b/src/Open5ETools.Web/ConfigureServices.cs @@ -6,6 +6,7 @@ using Open5ETools.Web.Services; using Serilog; using System.Globalization; +using Open5ETools.Web.Automapper; namespace Open5ETools.Web; @@ -47,6 +48,7 @@ public static IServiceCollection AddWebServices(this IServiceCollection services options.AccessDeniedPath = new PathString("/Auth/Forbidden/"); }); + services.AddAutoMapper(cfg => { cfg.AllowNullCollections = true; }, typeof(AuthProfile)); services.AddMemoryCache(); services.AddMvc() @@ -77,7 +79,7 @@ public static IHostBuilder AddSerilog(this IHostBuilder host, default: throw new ServiceException( string.Format(Resources.Error.DbProviderError, - configuration.GetConnectionString(AppDbContext.DbProvider))); + configuration.GetConnectionString(AppDbContext.DbProvider))); } return host; diff --git a/src/Open5ETools.Web/Controllers/Web/EncounterController.cs b/src/Open5ETools.Web/Controllers/Web/EncounterController.cs index ff03dfb..5f1bcdf 100644 --- a/src/Open5ETools.Web/Controllers/Web/EncounterController.cs +++ b/src/Open5ETools.Web/Controllers/Web/EncounterController.cs @@ -60,7 +60,7 @@ public async Task Generate(EncounterOptionViewModel optionModel) try { var encounters = await _encounterService.GenerateAsync(option); - var model = new EncounterViewModel() + var model = new EncounterViewModel { Details = encounters.Monsters.Select(_mapper.Map), SumXp = encounters.SumXp diff --git a/src/Open5ETools.Web/Controllers/Web/SpellController.cs b/src/Open5ETools.Web/Controllers/Web/SpellController.cs index 24f1274..3b37b2f 100644 --- a/src/Open5ETools.Web/Controllers/Web/SpellController.cs +++ b/src/Open5ETools.Web/Controllers/Web/SpellController.cs @@ -4,7 +4,6 @@ using Open5ETools.Core.Common.Interfaces.Services.SM; using Open5ETools.Web.Models; using Open5ETools.Web.Models.Spell; -using X.PagedList; namespace Open5ETools.Web.Controllers.Web; diff --git a/src/Open5ETools.Web/Dockerfile b/src/Open5ETools.Web/Dockerfile index 9acc895..e7d8592 100644 --- a/src/Open5ETools.Web/Dockerfile +++ b/src/Open5ETools.Web/Dockerfile @@ -1,11 +1,11 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /app COPY . ./ RUN dotnet restore ./src/Open5ETools.Web/Open5ETools.Web.csproj RUN dotnet publish "src/Open5ETools.Web/Open5ETools.Web.csproj" -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 WORKDIR /app COPY --from=build /app/out ./ diff --git a/src/Open5ETools.Web/Models/XPagedListViewModel.cs b/src/Open5ETools.Web/Models/XPagedListViewModel.cs index 789e280..7c39206 100644 --- a/src/Open5ETools.Web/Models/XPagedListViewModel.cs +++ b/src/Open5ETools.Web/Models/XPagedListViewModel.cs @@ -1,5 +1,6 @@ using Open5ETools.Core.Common.Extensions; using X.PagedList; +using X.PagedList.Extensions; namespace Open5ETools.Web.Models; diff --git a/src/Open5ETools.Web/Open5ETools.Web.csproj b/src/Open5ETools.Web/Open5ETools.Web.csproj index 4439c46..a54c9be 100644 --- a/src/Open5ETools.Web/Open5ETools.Web.csproj +++ b/src/Open5ETools.Web/Open5ETools.Web.csproj @@ -1,29 +1,29 @@ - - net8.0 - enable - enable - true - true - 1.0.1.0 - + + net9.0 + enable + enable + true + true + 1.0.2.0 + - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + diff --git a/src/Open5ETools.Web/Views/Shared/_CookieConsentPartial.cshtml b/src/Open5ETools.Web/Views/Shared/_CookieConsentPartial.cshtml index fd744b8..ebd11cd 100644 --- a/src/Open5ETools.Web/Views/Shared/_CookieConsentPartial.cshtml +++ b/src/Open5ETools.Web/Views/Shared/_CookieConsentPartial.cshtml @@ -8,20 +8,21 @@ @if (showBanner) { - - + + } \ No newline at end of file diff --git a/src/Open5ETools.Web/Views/Shared/_Layout.cshtml b/src/Open5ETools.Web/Views/Shared/_Layout.cshtml index 72e75ae..2e1387a 100644 --- a/src/Open5ETools.Web/Views/Shared/_Layout.cshtml +++ b/src/Open5ETools.Web/Views/Shared/_Layout.cshtml @@ -2,85 +2,90 @@ - - + + @ViewData["Title"] - Open5ETools - + -
- -
+ + + +
+ +
+ @RenderBody() +
+
+ +
- -
- @RenderBody() -
+ © @Resources.Common.Copyright - + @System.Reflection.Assembly.GetEntryAssembly()?.GetName().Version?.ToString() - @Resources.Common.Privacy
+
-
-
- © @Resources.Common.Copyright - - @System.Reflection.Assembly.GetEntryAssembly()?.GetName().Version?.ToString() - @Resources.Common.Privacy -
-
+ - - - + - - @RenderSection("Scripts", required: false) + +@await RenderSectionAsync("Scripts", required: false) diff --git a/src/Open5ETools.Web/Views/Shared/_Login.cshtml b/src/Open5ETools.Web/Views/Shared/_Login.cshtml index 2f94756..714222f 100644 --- a/src/Open5ETools.Web/Views/Shared/_Login.cshtml +++ b/src/Open5ETools.Web/Views/Shared/_Login.cshtml @@ -1,11 +1,12 @@ @using Open5ETools.Web.Helpers -@if (User?.Identity?.IsAuthenticated == true) +@if (User.Identity?.IsAuthenticated == true) {