public IActionResult DeleteConfirmed(int id)
        {
            Suggestion thisSuggestion = suggestionRepo.Suggestions.FirstOrDefault(suggestion => suggestion.SuggestionId == id);

            suggestionRepo.Remove(thisSuggestion);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public void DeleteSuggestion(Int64 suggestionId)
        {
            var temp = _suggestionRepository.Get(suggestionId);

            if (temp != null)
            {
                _suggestionRepository.Remove(temp);
                _suggestionRepository.UnitOfWork.Commit();
            }
        }
Exemplo n.º 3
0
        public async Task <SuggestionResponse> DeleteAsync(int id)
        {
            var existingSuggestion = await _suggestionRepository.FindById(id);

            if (existingSuggestion == null)
            {
                return(new SuggestionResponse("Suggestion not found"));
            }

            try
            {
                _suggestionRepository.Remove(existingSuggestion);
                await _unitOfWork.CompleteAsync();

                return(new SuggestionResponse(existingSuggestion));
            }
            catch (Exception ex)
            {
                return(new SuggestionResponse($"An error ocurred while deleting the Suggestion: {ex.Message}"));
            }
        }