public ResultViewModel RemoveAction(int id, int actionId) { var nonconformity = _nonconformityRepository.GetById(id); if (nonconformity == null) { return(new ResultViewModel(false, id, "Nonconformity does not exist!")); } var action = nonconformity?.Actions?.FirstOrDefault(p => p.Id == actionId); if (action == null) { return(new ResultViewModel(false, actionId, "Nonconformity does not contain this action!")); } _actionRepository.Remove(action); return(new ResultViewModel(true, nonconformity.Id, "Action successfully removed!")); }