diff --git a/DbFirst.API/Controllers/CatalogsController.cs b/DbFirst.API/Controllers/CatalogsController.cs index 254b39d..92518b8 100644 --- a/DbFirst.API/Controllers/CatalogsController.cs +++ b/DbFirst.API/Controllers/CatalogsController.cs @@ -50,17 +50,6 @@ public class CatalogsController : ControllerBase [HttpPut("{id:int}")] public async Task> Update(int id, CatalogWriteDto dto, CancellationToken cancellationToken) { - var current = await _mediator.Send(new GetCatalogByIdQuery(id), cancellationToken); - if (current == null) - { - return NotFound(); - } - if (dto.UpdateProcedure == CatalogUpdateProcedure.Update && - !string.Equals(current.CatTitle, dto.CatTitle, StringComparison.OrdinalIgnoreCase)) - { - return BadRequest("Titel kann nicht geändert werden."); - } - var updated = await _mediator.Send(new UpdateCatalogCommand(id, dto), cancellationToken); if (updated == null) { diff --git a/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs b/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs index 9e25ef5..193cd1a 100644 --- a/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs +++ b/DbFirst.Application/Catalogs/Commands/UpdateCatalogHandler.cs @@ -25,18 +25,20 @@ public class UpdateCatalogHandler : IRequestHandler(request.Dto); entity.Guid = request.Id; - entity.CatTitle = request.Dto.UpdateProcedure == CatalogUpdateProcedure.Update - ? existing.CatTitle - : request.Dto.CatTitle; entity.AddedWho = existing.AddedWho; entity.AddedWhen = existing.AddedWhen; entity.ChangedWho = "system"; entity.ChangedWhen = DateTime.UtcNow; - var procedure = request.Dto.UpdateProcedure; - var updated = await _repository.UpdateAsync(request.Id, entity, procedure, cancellationToken); + var updated = await _repository.UpdateAsync(request.Id, entity, request.Dto.UpdateProcedure, cancellationToken); return updated == null ? null : _mapper.Map(updated); } }