Пример #1
0
        public async Task <ToDoListResponse> SaveAsync(ToDoListItem toDoListItem)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    toDoListItem.Id = _userRepository.GetUserID();
                    await _toDoListRepository.AddAsync(toDoListItem);

                    await _unitOfWork.CompleteAsync();

                    scope.Complete();
                }

                return(new ToDoListResponse(toDoListItem));
            }
            catch (Exception ex)
            {
                return(new ToDoListResponse($"An error occurred when saving the toDoListItem: {ex.Message}"));
            }
        }