diff --git a/DbFirst.API/Controllers/CatalogsController.cs b/DbFirst.API/Controllers/CatalogsController.cs index 103d386..254b39d 100644 --- a/DbFirst.API/Controllers/CatalogsController.cs +++ b/DbFirst.API/Controllers/CatalogsController.cs @@ -1,6 +1,7 @@ using DbFirst.Application.Catalogs; using DbFirst.Application.Catalogs.Commands; using DbFirst.Application.Catalogs.Queries; +using DbFirst.Domain; using MediatR; using Microsoft.AspNetCore.Mvc; @@ -54,7 +55,8 @@ public class CatalogsController : ControllerBase { return NotFound(); } - if (!string.Equals(current.CatTitle, dto.CatTitle, StringComparison.OrdinalIgnoreCase)) + if (dto.UpdateProcedure == CatalogUpdateProcedure.Update && + !string.Equals(current.CatTitle, dto.CatTitle, StringComparison.OrdinalIgnoreCase)) { return BadRequest("Titel kann nicht geändert werden."); } diff --git a/DbFirst.Application/Catalogs/CatalogService.cs b/DbFirst.Application/Catalogs/CatalogService.cs index dbf5904..5d0d403 100644 --- a/DbFirst.Application/Catalogs/CatalogService.cs +++ b/DbFirst.Application/Catalogs/CatalogService.cs @@ -60,7 +60,7 @@ public class CatalogService : ICatalogService var entity = _mapper.Map(dto); entity.Guid = id; - entity.CatTitle = existing.CatTitle; + entity.CatTitle = dto.UpdateProcedure == CatalogUpdateProcedure.Update ? existing.CatTitle : dto.CatTitle; entity.AddedWho = existing.AddedWho; entity.AddedWhen = existing.AddedWhen; entity.ChangedWho = "system"; diff --git a/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs b/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs index 016e438..e236981 100644 --- a/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs +++ b/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs @@ -27,7 +27,9 @@ public class UpdateCatalogHandler : IRequestHandler(request.Dto); entity.Guid = request.Id; - entity.CatTitle = existing.CatTitle; + entity.CatTitle = request.Dto.UpdateProcedure == CatalogUpdateProcedure.Update + ? existing.CatTitle + : request.Dto.CatTitle; entity.AddedWho = existing.AddedWho; entity.AddedWhen = existing.AddedWhen; entity.ChangedWho = "system"; diff --git a/DbFirst.BlazorWasm/Pages/Catalogs.razor b/DbFirst.BlazorWasm/Pages/Catalogs.razor index 2c2ef09..5d83a3a 100644 --- a/DbFirst.BlazorWasm/Pages/Catalogs.razor +++ b/DbFirst.BlazorWasm/Pages/Catalogs.razor @@ -24,7 +24,7 @@ else if (!string.IsNullOrWhiteSpace(infoMessage))
- +