コード例 #1
0
 /// <summary>
 /// Removes a Quiz by Id and any associated objects. Updates log.
 /// </summary>
 /// <param name="id">The id of the quiz</param>
 public void DeleteQuiz(int id)
 {
     _logger.LogInformation($"Deleting Quiz with ID {id}");
     Entities.Quiz quiz = _dbContext.Quiz.Find(id);
     _dbContext.Remove(quiz);
     _dbContext.SaveChanges();
 }
コード例 #2
0
        public async Task <bool> DeleteQuestion(int id)
        {
            _logger.LogInformation($"Deleting Question with ID {id}");
            Entities.Question question = await _dbContext.Question.FindAsync(id);

            if (question == null)
            {
                return(false);
            }
            _dbContext.Remove(question);
            await _dbContext.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
 /// <summary>
 /// Removes a User from the database with a specific ID and updatest the log
 /// </summary>
 /// <param name="id">ID of the User to be deleted</param>
 public void DeleteUser(int id)
 {
     _logger.LogInformation($"Deleting user with ID {id}");
     DataAccess.Entities.User user = _dbContext.User.Find(id);
     _dbContext.Remove(user);
 }