SHA256
feat StayExport - Added delete for StayExports.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using FluentValidation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Somnia.GuestLog.Enums.Services;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
using Somnia.GuestLog.Models;
|
||||
using Somnia.GuestLog.Models.DTOs;
|
||||
@@ -59,6 +60,33 @@ public class StayExportFileEntityService(
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<Result> DeleteStayExportAsync(StayExportFileDTO dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var dbContext = contextFactory.CreateDbContext();
|
||||
|
||||
int deletedCount = await dbContext.StayExportFiles
|
||||
.Where(e => e.Id == dto.Id)
|
||||
.ExecuteDeleteAsync();
|
||||
|
||||
if (deletedCount == 0)
|
||||
{
|
||||
logger.LogWarning("StayExportFileService - DeleteStayExportAsync: Error deleting StayExport. Entity not found with ID: '{ID}'", dto.Id);
|
||||
return Result.Fail(ResultCode.NotFound);
|
||||
}
|
||||
|
||||
logger.LogInformation(
|
||||
"StayExportFileService - DeleteStayExportAsync: StayExport deleted with Id: '{id}'.", dto.Id);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "StayExportFileService - DeleteStayExportAsync: Error creating GuestDocument");
|
||||
return Result.FailUnknownError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<StayExportFileDTO?> GetDtoByIdAsync(long id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user