public IActionResult GetSuggestions(int id) { IEnumerable <Suggestion> _userSuggestions = _suggestionRepository.FindBy(s => s.CreatorId == id); if (_userSuggestions == null) { return(NotFound()); } IEnumerable <SuggestionViewModel> _userSuggestionsVM = Mapper.Map <IEnumerable <Suggestion>, IEnumerable <SuggestionViewModel> >(_userSuggestions); return(new OkObjectResult(_userSuggestionsVM)); }
public IActionResult Delete(int id) { Role _roleDb = _roleRepository.GetSingle(id); if (_roleDb == null) { return(new NotFoundResult()); } IEnumerable <UserRole> _userRoles = _userRoleRepository.FindBy(s => s.RoleId == id); foreach (var userRole in _userRoles) { IEnumerable <Suggestion> _suggestions = _suggestionRepository.FindBy(s => s.CreatorId == userRole.UserId); foreach (var suggestion in _suggestions) { _suggestionRepository.Delete(suggestion); } _userRepository.DeleteWhere(u => u.Id == userRole.UserId); _userRoleRepository.Delete(userRole); } _roleRepository.Delete(_roleDb); _roleRepository.Commit(); return(new NoContentResult()); }