Exemplo n.º 1
0
        public async Task <FeedQuizResult> CreateQuizResult(FeedQuizResult result, int QuizId)
        {
            using (var conn = new MySqlConnection(connString)) //New temporary connection
            {
                await conn.OpenAsync();                        //Opens connection

                using (var cmd = new MySqlCommand($"INSERT INTO feed_quiz_result VALUES({0}, {QuizId}, {result.UserId}, {result.OverallScore}, '{result.DatePosted.ToString("yyyy-MM-dd hh:mm:ss")}');", conn))
                {                                                             //^ inserts values into feed_quiz_result row
                    await cmd.ExecuteNonQueryAsync();                         //Executes command

                    return(await GetQuizResultById((int)cmd.LastInsertedId)); //Get returned reuslt row
                }
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> CreateQuizResult(int PostId, [FromBody] FeedQuizResult result)
 {
     return(Ok(await new FeedTasks().CreateQuizResult(result, PostId)));
 }