Example #1
0
        public async Task <IActionResult> SendMessage(int userId, CreateMessageDto messageForCreationDto)
        {
            var source = await _szkolniakRepo.GetUser(userId);

            messageForCreationDto.SenderId = userId;
            var message = _map.Map <Message>(messageForCreationDto);

            _szkolniakRepo.AddToRepo(message);
            await _szkolniakRepo.SaveAll();

            var messageToReturn = _map.Map <MessageToReturnDto>(message);

            return(CreatedAtRoute("GetMessage", new { userId, id = message.Id }, messageToReturn));
        }
        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");
        }