Exemplo n.º 1
0
        public async Task <DocResponse> UpdateAsync(int id, Doc doc)
        {
            var existingDoc = await _docRepository.FindByIdAsync(id);

            if (existingDoc == null)
            {
                return(new DocResponse("Doc not found."));
            }

            existingDoc.Name = doc.Name;

            try
            {
                _docRepository.Update(existingDoc);
                await _unitOfWork.CompleteAsync();

                return(new DocResponse(existingDoc));
            }
            catch (Exception ex)
            {
                return(new DocResponse($"An error occurred when updating the doc: {ex.Message}"));
            }
        }