Compare commits
11 Commits
c73c7e63fe
...
f54de87ca2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f54de87ca2 | ||
|
|
1b4205219f | ||
|
|
b35c167648 | ||
|
|
087708dcf7 | ||
|
|
be40c39f47 | ||
|
|
4fa3bcae3d | ||
|
|
612d8371d3 | ||
|
|
b7e66ab5f9 | ||
|
|
95a388015a | ||
|
|
c16f0483c3 | ||
|
|
83292f23f3 |
@@ -1,7 +1,6 @@
|
||||
using DbFirst.Application.Catalogs;
|
||||
using DbFirst.Application.Catalogs.Commands;
|
||||
using DbFirst.Application.Catalogs.Queries;
|
||||
using DbFirst.Domain;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class CatalogsController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<CatalogReadDto>> Create(CatalogWriteDto dto, CancellationToken cancellationToken)
|
||||
public async Task<ActionResult<CatalogReadDto>> Create([FromBody]CatalogWriteDto dto, CancellationToken cancellationToken)
|
||||
{
|
||||
var created = await _mediator.Send(new CreateCatalogCommand(dto), cancellationToken);
|
||||
if (created == null)
|
||||
@@ -48,7 +47,7 @@ public class CatalogsController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPut("{id:int}")]
|
||||
public async Task<ActionResult<CatalogReadDto>> Update(int id, CatalogWriteDto dto, CancellationToken cancellationToken)
|
||||
public async Task<ActionResult<CatalogReadDto>> Update(int id, [FromBody] CatalogWriteDto dto, CancellationToken cancellationToken)
|
||||
{
|
||||
var updated = await _mediator.Send(new UpdateCatalogCommand(id, dto), cancellationToken);
|
||||
if (updated == null)
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MassDataController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("upsert")]
|
||||
public async Task<ActionResult<MassDataReadDto>> Upsert(MassDataWriteDto dto, CancellationToken cancellationToken)
|
||||
public async Task<ActionResult<MassDataReadDto>> Upsert([FromBody]MassDataWriteDto dto, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new UpsertMassDataByCustomerNameCommand(dto), cancellationToken);
|
||||
return Ok(result);
|
||||
|
||||
@@ -6,14 +6,23 @@ namespace DbFirst.API.Dashboards;
|
||||
public class DashboardChangeNotifier : IDashboardChangeNotifier
|
||||
{
|
||||
private readonly IHubContext<DashboardsHub> _hubContext;
|
||||
private readonly ILogger<DashboardChangeNotifier> _logger;
|
||||
|
||||
public DashboardChangeNotifier(IHubContext<DashboardsHub> hubContext)
|
||||
public DashboardChangeNotifier(IHubContext<DashboardsHub> hubContext, ILogger<DashboardChangeNotifier> logger)
|
||||
{
|
||||
_hubContext = hubContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void NotifyChanged()
|
||||
public async Task NotifyChangedAsync()
|
||||
{
|
||||
_ = _hubContext.Clients.All.SendAsync("DashboardsChanged");
|
||||
try
|
||||
{
|
||||
await _hubContext.Clients.All.SendAsync("DashboardsChanged");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to notify dashboard clients.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
115
DbFirst.API/Dashboards/DashboardConfiguratorFactory.cs
Normal file
115
DbFirst.API/Dashboards/DashboardConfiguratorFactory.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using DbFirst.Domain.Entities;
|
||||
using DevExpress.DashboardCommon;
|
||||
using DevExpress.DashboardWeb;
|
||||
using DevExpress.DataAccess.Json;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace DbFirst.API.Dashboards;
|
||||
|
||||
public static class DashboardConfiguratorFactory
|
||||
{
|
||||
public static DashboardConfigurator Create(
|
||||
IServiceProvider serviceProvider,
|
||||
IConfiguration configuration,
|
||||
IWebHostEnvironment environment)
|
||||
{
|
||||
// Den gesamten Inhalt des Lambdas hierher verschieben
|
||||
// serviceProvider, configuration, environment statt builder.* verwenden
|
||||
|
||||
var dashboardsPath = Path.Combine(environment.ContentRootPath, "Data", "Dashboards");
|
||||
Directory.CreateDirectory(dashboardsPath);
|
||||
|
||||
var defaultDashboardPath = Path.Combine(dashboardsPath, "DefaultDashboard.xml");
|
||||
if (!File.Exists(defaultDashboardPath))
|
||||
{
|
||||
var defaultDashboard = new Dashboard();
|
||||
defaultDashboard.Title.Text = "Default Dashboard";
|
||||
defaultDashboard.SaveToXml(defaultDashboardPath);
|
||||
}
|
||||
|
||||
var dashboardBaseUrl = configuration["Dashboard:BaseUrl"]
|
||||
?? configuration["ApiBaseUrl"]
|
||||
?? configuration["ASPNETCORE_URLS"]?.Split(';', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault()
|
||||
?? "https://localhost:7204";
|
||||
|
||||
dashboardBaseUrl = dashboardBaseUrl.TrimEnd('/');
|
||||
|
||||
var catalogsGridDashboardPath = Path.Combine(dashboardsPath, "CatalogsGrid.xml");
|
||||
if (!File.Exists(catalogsGridDashboardPath))
|
||||
{
|
||||
var dashboard = new Dashboard();
|
||||
dashboard.Title.Text = "Catalogs (Dashboard Grid)";
|
||||
|
||||
var catalogDataSource = new DashboardJsonDataSource("Catalogs (API)")
|
||||
{
|
||||
ComponentName = "catalogsDataSource",
|
||||
JsonSource = new UriJsonSource(new Uri($"{dashboardBaseUrl}/api/catalogs"))
|
||||
};
|
||||
|
||||
dashboard.DataSources.Add(catalogDataSource);
|
||||
|
||||
var grid = new GridDashboardItem
|
||||
{
|
||||
DataSource = catalogDataSource,
|
||||
Name = "Catalogs"
|
||||
};
|
||||
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.Guid))) { Name = "Id" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.CatTitle))) { Name = "Titel" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.CatString))) { Name = "String" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.AddedWho))) { Name = "Angelegt von" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.AddedWhen))) { Name = "Angelegt am" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.ChangedWho))) { Name = "Geändert von" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.ChangedWhen))) { Name = "Geändert am" });
|
||||
|
||||
dashboard.Items.Add(grid);
|
||||
|
||||
var layoutGroup = new DashboardLayoutGroup { Orientation = DashboardLayoutGroupOrientation.Vertical };
|
||||
layoutGroup.ChildNodes.Add(new DashboardLayoutItem(grid));
|
||||
dashboard.LayoutRoot = layoutGroup;
|
||||
|
||||
dashboard.SaveToXml(catalogsGridDashboardPath);
|
||||
}
|
||||
|
||||
DashboardConfigurator configurator = new DashboardConfigurator();
|
||||
|
||||
var connectionString = configuration.GetConnectionString("DefaultConnection") ?? string.Empty;
|
||||
var notifier = serviceProvider.GetRequiredService<IDashboardChangeNotifier>();
|
||||
var dashboardStorage = new SqlDashboardStorage(connectionString, "TBDD_SMF_CONFIG", notifier: notifier);
|
||||
configurator.SetDashboardStorage(dashboardStorage);
|
||||
|
||||
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
|
||||
DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)");
|
||||
jsonDataSourceUrl.JsonSource = new UriJsonSource(
|
||||
new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"));
|
||||
jsonDataSourceUrl.RootElement = "Customers";
|
||||
dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml());
|
||||
|
||||
var catalogsJsonDataSource = new DashboardJsonDataSource("Catalogs (API)")
|
||||
{
|
||||
ComponentName = "catalogsDataSource",
|
||||
JsonSource = new UriJsonSource(new Uri($"{dashboardBaseUrl}/api/catalogs"))
|
||||
};
|
||||
dataSourceStorage.RegisterDataSource(catalogsJsonDataSource.ComponentName, catalogsJsonDataSource.SaveToXml());
|
||||
dataSourceStorage.RegisterDataSource(catalogsJsonDataSource.Name, catalogsJsonDataSource.SaveToXml());
|
||||
|
||||
configurator.SetDataSourceStorage(dataSourceStorage);
|
||||
|
||||
EnsureDashboardInStorage(dashboardStorage, "DefaultDashboard", defaultDashboardPath);
|
||||
EnsureDashboardInStorage(dashboardStorage, "CatalogsGrid", catalogsGridDashboardPath);
|
||||
|
||||
return configurator;
|
||||
}
|
||||
|
||||
private static void EnsureDashboardInStorage(IEditableDashboardStorage storage, string id, string filePath)
|
||||
{
|
||||
var exists = storage.GetAvailableDashboardsInfo().Any(info => string.Equals(info.ID, id, StringComparison.OrdinalIgnoreCase));
|
||||
if (exists || !File.Exists(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var doc = XDocument.Load(filePath);
|
||||
storage.AddDashboard(doc, id);
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@ namespace DbFirst.API.Dashboards;
|
||||
|
||||
public interface IDashboardChangeNotifier
|
||||
{
|
||||
void NotifyChanged();
|
||||
Task NotifyChangedAsync();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public sealed class SqlDashboardStorage : IEditableDashboardStorage
|
||||
|
||||
connection.Open();
|
||||
command.ExecuteNonQuery();
|
||||
_notifier?.NotifyChanged();
|
||||
_ = _notifier?.NotifyChangedAsync();
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public sealed class SqlDashboardStorage : IEditableDashboardStorage
|
||||
throw new ArgumentException($"Dashboard '{dashboardId}' not found.");
|
||||
}
|
||||
|
||||
_notifier?.NotifyChanged();
|
||||
_ = _notifier?.NotifyChangedAsync();
|
||||
}
|
||||
|
||||
public void DeleteDashboard(string dashboardId)
|
||||
@@ -133,6 +133,6 @@ public sealed class SqlDashboardStorage : IEditableDashboardStorage
|
||||
|
||||
connection.Open();
|
||||
command.ExecuteNonQuery();
|
||||
_notifier?.NotifyChanged();
|
||||
_ = _notifier?.NotifyChangedAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DbFirst.API.Middleware;
|
||||
|
||||
@@ -20,33 +19,35 @@ public class ExceptionHandlingMiddleware
|
||||
{
|
||||
await _next(context);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Domain validation error");
|
||||
await WriteProblemAsync(context, StatusCodes.Status400BadRequest, "Eingabe ungültig", ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Unhandled exception");
|
||||
await WriteProblemDetailsAsync(context, ex);
|
||||
await WriteProblemAsync(context, StatusCodes.Status500InternalServerError, "Serverfehler", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task WriteProblemDetailsAsync(HttpContext context, Exception ex)
|
||||
private static async Task WriteProblemAsync(HttpContext context, int status, string title, string detail)
|
||||
{
|
||||
if (context.Response.HasStarted)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
if (context.Response.HasStarted) return;
|
||||
|
||||
context.Response.Clear();
|
||||
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
context.Response.ContentType = "application/json";
|
||||
context.Response.StatusCode = status;
|
||||
context.Response.ContentType = "application/problem+json";
|
||||
|
||||
var problem = new
|
||||
var problem = new ProblemDetails
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.6.1",
|
||||
title = "Serverfehler",
|
||||
status = context.Response.StatusCode,
|
||||
detail = ex.Message,
|
||||
traceId = context.TraceIdentifier
|
||||
Type = $"https://tools.ietf.org/html/rfc9110#section-{(status == 400 ? "15.5.1" : "15.6.1")}",
|
||||
Title = title,
|
||||
Status = status,
|
||||
Detail = detail,
|
||||
Extensions = { ["traceId"] = context.TraceIdentifier }
|
||||
};
|
||||
|
||||
await context.Response.WriteAsync(JsonSerializer.Serialize(problem));
|
||||
await context.Response.WriteAsJsonAsync(problem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
using DbFirst.API.Middleware;
|
||||
using DbFirst.API.Dashboards;
|
||||
using DbFirst.API.Hubs;
|
||||
using DbFirst.API.Middleware;
|
||||
using DbFirst.Application;
|
||||
using DbFirst.Domain;
|
||||
using DbFirst.Domain.Entities;
|
||||
using DbFirst.Infrastructure;
|
||||
using DevExpress.AspNetCore;
|
||||
using DevExpress.DashboardAspNetCore;
|
||||
using DevExpress.DashboardCommon;
|
||||
using DevExpress.DashboardWeb;
|
||||
using DevExpress.DataAccess.Json;
|
||||
using System.Xml.Linq;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -18,6 +13,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddProblemDetails();
|
||||
|
||||
// TODO: allow listed origins configured in appsettings.json
|
||||
// In any case, dont let them to free to use without cors. if there is no origin specified, block all.
|
||||
@@ -34,7 +30,7 @@ builder.Services.AddCors(options =>
|
||||
}
|
||||
else
|
||||
{
|
||||
var origins = builder.Configuration.GetSection("Cors:AllowedOrigins").Get<string[]>() ?? Array.Empty<string>();
|
||||
var origins = builder.Configuration.GetSection("Cors:AllowedOrigins").Get<string[]>() ?? [];
|
||||
if (origins.Length > 0)
|
||||
{
|
||||
policy.WithOrigins(origins)
|
||||
@@ -52,91 +48,8 @@ builder.Services.AddApplication();
|
||||
builder.Services.AddDevExpressControls();
|
||||
builder.Services.AddSignalR();
|
||||
builder.Services.AddSingleton<IDashboardChangeNotifier, DashboardChangeNotifier>();
|
||||
builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
|
||||
var dashboardsPath = Path.Combine(builder.Environment.ContentRootPath, "Data", "Dashboards");
|
||||
Directory.CreateDirectory(dashboardsPath);
|
||||
|
||||
var defaultDashboardPath = Path.Combine(dashboardsPath, "DefaultDashboard.xml");
|
||||
if (!File.Exists(defaultDashboardPath))
|
||||
{
|
||||
var defaultDashboard = new Dashboard();
|
||||
defaultDashboard.Title.Text = "Default Dashboard";
|
||||
defaultDashboard.SaveToXml(defaultDashboardPath);
|
||||
}
|
||||
|
||||
var dashboardBaseUrl = builder.Configuration["Dashboard:BaseUrl"]
|
||||
?? builder.Configuration["ApiBaseUrl"]
|
||||
?? builder.Configuration["ASPNETCORE_URLS"]?.Split(';', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault()
|
||||
?? "https://localhost:7204";
|
||||
|
||||
dashboardBaseUrl = dashboardBaseUrl.TrimEnd('/');
|
||||
|
||||
var catalogsGridDashboardPath = Path.Combine(dashboardsPath, "CatalogsGrid.xml");
|
||||
if (!File.Exists(catalogsGridDashboardPath))
|
||||
{
|
||||
var dashboard = new Dashboard();
|
||||
dashboard.Title.Text = "Catalogs (Dashboard Grid)";
|
||||
|
||||
var catalogDataSource = new DashboardJsonDataSource("Catalogs (API)")
|
||||
{
|
||||
ComponentName = "catalogsDataSource",
|
||||
JsonSource = new UriJsonSource(new Uri($"{dashboardBaseUrl}/api/catalogs"))
|
||||
};
|
||||
|
||||
dashboard.DataSources.Add(catalogDataSource);
|
||||
|
||||
var grid = new GridDashboardItem
|
||||
{
|
||||
DataSource = catalogDataSource,
|
||||
Name = "Catalogs"
|
||||
};
|
||||
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.Guid))) { Name = "Id" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.CatTitle))) { Name = "Titel" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.CatString))) { Name = "String" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.AddedWho))) { Name = "Angelegt von" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.AddedWhen))) { Name = "Angelegt am" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.ChangedWho))) { Name = "Geändert von" });
|
||||
grid.Columns.Add(new GridDimensionColumn(new Dimension(nameof(VwmyCatalog.ChangedWhen))) { Name = "Geändert am" });
|
||||
|
||||
dashboard.Items.Add(grid);
|
||||
|
||||
var layoutGroup = new DashboardLayoutGroup { Orientation = DashboardLayoutGroupOrientation.Vertical };
|
||||
layoutGroup.ChildNodes.Add(new DashboardLayoutItem(grid));
|
||||
dashboard.LayoutRoot = layoutGroup;
|
||||
|
||||
dashboard.SaveToXml(catalogsGridDashboardPath);
|
||||
}
|
||||
|
||||
DashboardConfigurator configurator = new DashboardConfigurator();
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? string.Empty;
|
||||
var notifier = serviceProvider.GetRequiredService<IDashboardChangeNotifier>();
|
||||
var dashboardStorage = new SqlDashboardStorage(connectionString, "TBDD_SMF_CONFIG", notifier: notifier);
|
||||
configurator.SetDashboardStorage(dashboardStorage);
|
||||
|
||||
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
|
||||
DashboardJsonDataSource jsonDataSourceUrl = new DashboardJsonDataSource("JSON Data Source (URL)");
|
||||
jsonDataSourceUrl.JsonSource = new UriJsonSource(
|
||||
new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"));
|
||||
jsonDataSourceUrl.RootElement = "Customers";
|
||||
dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml());
|
||||
|
||||
var catalogsJsonDataSource = new DashboardJsonDataSource("Catalogs (API)")
|
||||
{
|
||||
ComponentName = "catalogsDataSource",
|
||||
JsonSource = new UriJsonSource(new Uri($"{dashboardBaseUrl}/api/catalogs"))
|
||||
};
|
||||
dataSourceStorage.RegisterDataSource(catalogsJsonDataSource.ComponentName, catalogsJsonDataSource.SaveToXml());
|
||||
dataSourceStorage.RegisterDataSource(catalogsJsonDataSource.Name, catalogsJsonDataSource.SaveToXml());
|
||||
|
||||
configurator.SetDataSourceStorage(dataSourceStorage);
|
||||
|
||||
EnsureDashboardInStorage(dashboardStorage, "DefaultDashboard", defaultDashboardPath);
|
||||
EnsureDashboardInStorage(dashboardStorage, "CatalogsGrid", catalogsGridDashboardPath);
|
||||
|
||||
return configurator;
|
||||
});
|
||||
builder.Services.AddScoped<DashboardConfigurator>(sp =>
|
||||
DashboardConfiguratorFactory.Create(sp, builder.Configuration, builder.Environment));
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -159,15 +72,3 @@ app.MapHub<DashboardsHub>("/hubs/dashboards");
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
static void EnsureDashboardInStorage(IEditableDashboardStorage storage, string id, string filePath)
|
||||
{
|
||||
var exists = storage.GetAvailableDashboardsInfo().Any(info => string.Equals(info.ID, id, StringComparison.OrdinalIgnoreCase));
|
||||
if (exists || !File.Exists(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var doc = XDocument.Load(filePath);
|
||||
storage.AddDashboard(doc, id);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ namespace DbFirst.Application.Catalogs;
|
||||
public class CatalogReadDto
|
||||
{
|
||||
public int Guid { get; set; }
|
||||
public string CatTitle { get; set; } = null!;
|
||||
public string CatString { get; set; } = null!;
|
||||
public string AddedWho { get; set; } = null!;
|
||||
public string CatTitle { get; set; } = string.Empty;
|
||||
public string CatString { get; set; } = string.Empty;
|
||||
public string AddedWho { get; set; } = string.Empty;
|
||||
public DateTime AddedWhen { get; set; }
|
||||
public string? ChangedWho { get; set; }
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace DbFirst.Application.Catalogs;
|
||||
|
||||
public class CatalogWriteDto
|
||||
{
|
||||
public string CatTitle { get; set; } = null!;
|
||||
public string CatString { get; set; } = null!;
|
||||
public string CatTitle { get; set; } = string.Empty;
|
||||
public string CatString { get; set; } = string.Empty;
|
||||
public CatalogUpdateProcedure UpdateProcedure { get; set; } = CatalogUpdateProcedure.Update;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="MediatR" Version="14.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -8,7 +8,8 @@ public static class DependencyInjection
|
||||
public static IServiceCollection AddApplication(this IServiceCollection services)
|
||||
{
|
||||
services.AddAutoMapper(typeof(DependencyInjection).Assembly);
|
||||
services.AddMediatR(typeof(DependencyInjection).Assembly);
|
||||
services.AddMediatR(cfg =>
|
||||
cfg.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ namespace DbFirst.BlazorWebApp.Models;
|
||||
public class CatalogReadDto
|
||||
{
|
||||
public int Guid { get; set; }
|
||||
public string CatTitle { get; set; } = null!;
|
||||
public string CatString { get; set; } = null!;
|
||||
public string AddedWho { get; set; } = null!;
|
||||
public string CatTitle { get; set; } = string.Empty;
|
||||
public string CatString { get; set; } = string.Empty;
|
||||
public string AddedWho { get; set; } = string.Empty;
|
||||
public DateTime AddedWhen { get; set; }
|
||||
public string? ChangedWho { get; set; }
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace DbFirst.BlazorWebApp.Services;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using DbFirst.BlazorWebApp.Models;
|
||||
|
||||
namespace DbFirst.BlazorWebApp.Services;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Net.Http.Json;
|
||||
using DbFirst.BlazorWebApp.Models;
|
||||
|
||||
namespace DbFirst.BlazorWebApp.Services;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Net.Http.Json;
|
||||
using DbFirst.BlazorWebApp.Models;
|
||||
|
||||
namespace DbFirst.BlazorWebApp.Services;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Net.Http.Json;
|
||||
using DbFirst.BlazorWebApp.Models;
|
||||
|
||||
namespace DbFirst.BlazorWebApp.Services;
|
||||
|
||||
@@ -4,11 +4,11 @@ public partial class VwmyCatalog
|
||||
{
|
||||
public int Guid { get; set; }
|
||||
|
||||
public string CatTitle { get; set; } = null!;
|
||||
public string CatTitle { get; set; } = string.Empty;
|
||||
|
||||
public string CatString { get; set; } = null!;
|
||||
public string CatString { get; set; } = string.Empty;
|
||||
|
||||
public string AddedWho { get; set; } = null!;
|
||||
public string AddedWho { get; set; } = string.Empty;
|
||||
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -20,11 +20,6 @@ public class MassDataRepository : IMassDataRepository
|
||||
return await _db.Massdata.AsNoTracking().CountAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<List<Massdata>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _db.Massdata.AsNoTracking().ToListAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Massdata?> GetByCustomerNameAsync(string customerName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _db.Massdata.AsNoTracking()
|
||||
|
||||
Reference in New Issue
Block a user