public async Task HandleAsync(UpdatePollInput input, IUpdatePollOutputPort output) { try { Poll poll = await this.pollGateway.GetAsync(input.Id); if (poll is null) { output.NotFound("Poll not found!"); this.loggerService.LogInformation("Cannot retrieve a poll with {@id}", input.Id); return; } poll.SetTitle(input.Title); poll.SetDueDate(input.DueDate); await this.pollGateway.UpdateAsync(poll); output.Success(); } catch (DomainException ex) { this.loggerService.LogInformation("{@excepton} occured when trying to update a poll with {@input}", ex, input); output.Error(ex.Message); } }
public async Task <IActionResult> UpdatePoll(int id, UpdatePollRequest request) { var updatePollInput = new UpdatePollInput(id, request.Title, request.DueDate); await this.updatePollInputPort.HandleAsync(updatePollInput, this.updatePollPresenter); return(this.updatePollPresenter.ViewModel); }