public async Task <Example> UpdateExample(Guid id, Example request) { var oldExample = await _exampleRepository.GetByIdAsync(id); if (oldExample == null) { await _notifications.AddNotificationAsync(new DomainNotification("ExampleBusiness", "Example não encontrado.")); return(await Task.FromResult(request)); } var newExample = Example.ExampleFactory.UpdateExample(oldExample, request.Descricao); if (!await IsValidAsync(newExample)) { return(await Task.FromResult(request)); } _exampleRepository.Update(newExample); if (await Commit()) { return(await Task.FromResult(newExample)); } return(request); }
public async Task <ExampleGetOneResponse> GetOneAsync(int id) => await ExecuteAsync(async() => { var response = new ExampleGetOneResponse(); var banco = await _exampleRepository.GetByIdAsync(id, false).ConfigureAwait(false); if (banco != null) { response.Example = (ExampleDto)banco; } return(response); });