public async Task <CommandExecutionResult> HandleAsync(CreateClientCommand command) { command.ClientId = Guid.NewGuid(); var clientEntity = command.Adapt <ClientEntity>(); await _repository.InsertAsync(clientEntity); return(CommandExecutionResult.Success); }
public async Task <IActionResult> Add(CreateClientQuery query, CreateClientCommand command) { if (ModelState.IsValid == false) { var vm = BuildAddForm(command.Adapt <ClientEntity>()); return(View("FormView", vm)); } await _clientService.HandleAsync(command); return(Redirect(Url.AppUri(nameof(Edit), nameof(ClientController), new UpdateClientQuery(command.ClientId)))); }