public IActionResult DeleteConfirmed(int id) { Suggestion thisSuggestion = suggestionRepo.Suggestions.FirstOrDefault(suggestion => suggestion.SuggestionId == id); suggestionRepo.Remove(thisSuggestion); return(RedirectToAction("Index")); }
public void DeleteSuggestion(Int64 suggestionId) { var temp = _suggestionRepository.Get(suggestionId); if (temp != null) { _suggestionRepository.Remove(temp); _suggestionRepository.UnitOfWork.Commit(); } }
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}")); } }