using System; using LCU.Library.Internal.FileOperationsModels.Models; namespace LCU.Api.Internal.FileOperations.Services.FileActionServices; public static class OperationService { public static RequestResponse PerformOperation(T request, Func validate, Action 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; } } }