Ejemplo n.º 1
0
        protected IResponseStatus <TResponse> TryExecute <TResponse>(IRequest <TResponse> request, CommandFacade <TResponse> commandFacade)
            where TResponse : IResponse, new()
        {
            var validateResult = commandFacade.Validate(request);

            if (validateResult.IsValid)
            {
                try
                {
                    var response = commandFacade.Execute(request);
                    return(new OkResponseStatus <TResponse>(response));
                }
                catch (Exception e)
                {
                    //ErrorLogUtils.AddError(e);

                    var error = new InternalServerResponseError();
                    return(new ErrorResponseStatus <TResponse>(error));
                }
            }

            return(new ErrorResponseStatus <TResponse>(validateResult.ResponseError));
        }
Ejemplo n.º 2
0
 protected void AfterExecute <TResponse>(IRequest <TResponse> request, TResponse response, CommandFacade <TResponse> commandFacade)
     where TResponse : IResponse, new()
 {
     commandFacade.NotifyExecuted(request, response);
 }