Exemple #1
0
        protected async Task <IActionResult> ExecuteCommand <TResult>(ICommand <CommandResponse <TResult> > command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CommandResponse <TResult> response = await Dispatcher.DispatchAsync(command);

            if (response.IsSuccess)
            {
                return(Ok(response.Result));
            }
            response.AddToModelState(ModelState);
            return(BadRequest(ModelState));
        }
Exemple #2
0
        protected async Task <IActionResult> ExecuteCommand <TCommand, TResult>() where TCommand : class, ICommand <CommandResponse <TResult> >, new()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            TCommand command = CreateCommand <TCommand>();
            CommandResponse <TResult> response = await Dispatcher.DispatchAsync(command);

            if (response.IsSuccess)
            {
                return(Ok(response.Result));
            }
            response.AddToModelState(ModelState);
            return(BadRequest(ModelState));
        }