protected virtual IResult <TransactionType> GetTransactionType(Guid id) { try { var internalList = GetInternalList(); var internalItem = internalList.FirstOrDefault(i => i.Id == id); if (null == internalItem) { return(_resultFactory.Create <TransactionType>( ResultCode.NoContent, new List <Error>() { new Error(String.Format("No TransactionType found with Id {0}", id)) }, null)); } else { return(_resultFactory.Success(internalItem)); } } catch (Exception ex) { return(_resultFactory.Exception <TransactionType>(ApplicationSegment.Database, 0, ex)); } }
private async Task <object?> CallControllerAsync( IReadOnlyList <object?> arguments, MethodInfo method) { if (_methodValidation != null) { _methodValidation(method); } var callId = Guid.NewGuid(); var(url, actionInfo) = await _getInfo.GetInfo <T>(arguments.ToList(), method, _actionInfoTransformersCaller); using var request = HttpRequestFactory.Create( actionInfo.HttpMethod, url, actionInfo.Body, callId, actionInfo.BodyFormat, actionInfo.Headers, _serializer); CallDataDictionary.InsertEmptyDataToIndicateTestCall(callId); var result = await _webCaller.Call(request, actionInfo, new InvocationInfo(arguments, method)); return(await _resultFactory.Create <T>(result, callId.ToString(), method)); }
public Result ValidateTransaction(Transaction transaction) { if (transaction.Entries.Sum(e => e.Amount) == transaction.NetDifference) { return(_resultFactory.Success()); } else { return(_resultFactory.Create(new ResultCode(), new Error("Transaction does not balance"))); } }
public static IResult Success(this IResultFactory factory) { return(factory.Create()); }
public static IResult <TValue> Exception <TValue>(this IResultFactory factory, Exception ex) { return(factory.Create <TValue>(ex)); }
public static IResult Exception(this IResultFactory factory, Exception ex) { return(factory.Create(ex)); }
public static IResult <TValue> Success <TValue>(this IResultFactory factory, TValue value) { return(factory.Create(value)); }