Restrict CatTitle editing based on UpdateProcedure
Enforce business rules for catalog title changes: only allow CatTitle to be edited when UpdateProcedure permits, with checks in the API, service, handler, and UI. This ensures consistent validation and user experience across backend and frontend.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using DbFirst.Application.Catalogs;
|
using DbFirst.Application.Catalogs;
|
||||||
using DbFirst.Application.Catalogs.Commands;
|
using DbFirst.Application.Catalogs.Commands;
|
||||||
using DbFirst.Application.Catalogs.Queries;
|
using DbFirst.Application.Catalogs.Queries;
|
||||||
|
using DbFirst.Domain;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -54,7 +55,8 @@ public class CatalogsController : ControllerBase
|
|||||||
{
|
{
|
||||||
return NotFound();
|
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.");
|
return BadRequest("Titel kann nicht geändert werden.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class CatalogService : ICatalogService
|
|||||||
|
|
||||||
var entity = _mapper.Map<VwmyCatalog>(dto);
|
var entity = _mapper.Map<VwmyCatalog>(dto);
|
||||||
entity.Guid = id;
|
entity.Guid = id;
|
||||||
entity.CatTitle = existing.CatTitle;
|
entity.CatTitle = dto.UpdateProcedure == CatalogUpdateProcedure.Update ? existing.CatTitle : dto.CatTitle;
|
||||||
entity.AddedWho = existing.AddedWho;
|
entity.AddedWho = existing.AddedWho;
|
||||||
entity.AddedWhen = existing.AddedWhen;
|
entity.AddedWhen = existing.AddedWhen;
|
||||||
entity.ChangedWho = "system";
|
entity.ChangedWho = "system";
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ public class UpdateCatalogHandler : IRequestHandler<UpdateCatalogCommand, Catalo
|
|||||||
|
|
||||||
var entity = _mapper.Map<VwmyCatalog>(request.Dto);
|
var entity = _mapper.Map<VwmyCatalog>(request.Dto);
|
||||||
entity.Guid = request.Id;
|
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.AddedWho = existing.AddedWho;
|
||||||
entity.AddedWhen = existing.AddedWhen;
|
entity.AddedWhen = existing.AddedWhen;
|
||||||
entity.ChangedWho = "system";
|
entity.ChangedWho = "system";
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ else if (!string.IsNullOrWhiteSpace(infoMessage))
|
|||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">Titel</label>
|
<label class="form-label">Titel</label>
|
||||||
<InputText class="form-control" @bind-Value="formModel.CatTitle" disabled="@isEditing" />
|
<InputText class="form-control" @bind-Value="formModel.CatTitle" disabled="@(isEditing && formModel.UpdateProcedure == 0)" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">Kennung</label>
|
<label class="form-label">Kennung</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user