Enforce ID retrieval in UpdateAsync method
Updated the `UpdateAsync<TUpdateDto>` method in `CRUDService.cs` to replace the use of `GetIdOrDefault<TId>()` with `GetId<TId>()`. This change ensures that an ID must be present in the `updateDto`, enhancing the reliability of the update process.
This commit is contained in:
parent
68d78afafe
commit
b95baaef5f
@ -47,7 +47,7 @@ namespace DigitalData.Core.Application
|
|||||||
/// <returns>A service message indicating success or failure.</returns>
|
/// <returns>A service message indicating success or failure.</returns>
|
||||||
public virtual async Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto)
|
public virtual async Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto)
|
||||||
{
|
{
|
||||||
var currentEntitiy = await _repository.ReadByIdAsync(updateDto.GetIdOrDefault<TId>());
|
var currentEntitiy = await _repository.ReadByIdAsync(updateDto.GetId<TId>());
|
||||||
|
|
||||||
if (currentEntitiy is null)
|
if (currentEntitiy is null)
|
||||||
return Result.Fail().Notice(LogLevel.Warning, Flag.NotFound, $"{updateDto.GetIdOrDefault<TId>()} is not found in update process of {GetType()} entity.");
|
return Result.Fail().Notice(LogLevel.Warning, Flag.NotFound, $"{updateDto.GetIdOrDefault<TId>()} is not found in update process of {GetType()} entity.");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user