Files
monorepo/LCU.API.Internal.FileOperations/LCU.Api.Internal.FileOperations/Services/FileActionServices/OperationService.cs
T
2026-04-27 10:50:07 -05:00

30 lines
957 B
C#

using System;
using LCU.Library.Internal.FileOperationsModels.Models;
namespace LCU.Api.Internal.FileOperations.Services.FileActionServices;
public static class OperationService
{
public static RequestResponse PerformOperation<T>(T request,
Func<T, RequestResponse, RequestResponse> validate,
Action<T> action)
{
var requestResponse = new RequestResponse();
try
{
requestResponse = validate(request, requestResponse);
if (requestResponse.IsSuccessful)
{
action(request);
}
return requestResponse;
}
catch (Exception exception)
{
requestResponse.IsSuccessful = false;
requestResponse.MessageStack.Add(exception.Message);
return requestResponse;
}
}
}