public async Task <IActionResult> CreateQuiz(QuizForCreationDto quizForCreationDto) { var quiz = _mapper.Map <Quiz>(quizForCreationDto); _repo.AddToRepo(quiz); if (await _repo.SaveAll()) { return(Ok(quiz)); } throw new Exception("Nie udalo sie utworzyc quizu"); }
public IActionResult CreateQuiz(QuizForCreationDto quiz) { try { var quizEntity = _mapper.Map <Quiz>(quiz); _repository.Quiz.CreateQuiz(quizEntity); _repository.Save(); var createdOwner = _mapper.Map <QuizDto>(quizEntity); return(Ok(createdOwner.Id)); } catch (Exception ex) { _logger.LogError($"Something went wrong inside CreateQuiz action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }