/// <summary>
        /// Save Student quiz result in database
        /// </summary>
        /// <param name="result">quiz result</param>
        /// <returns>true/false</returns>
        public bool SaveQuizResult(int result, int TotalMarks)
        {
            try
            {
                QuizDetail quizDetail = new QuizDetail();
                quizDetail.Id          = Guid.NewGuid();
                quizDetail.UserId      = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());
                quizDetail.QuizId      = Guid.NewGuid();
                quizDetail.Result      = result;
                quizDetail.TotalMarks  = TotalMarks;
                quizDetail.Status      = true;
                quizDetail.DateCreated = DateTime.Now;
                quizDetail.IsActive    = true;

                using (var db = new MyLearnDBEntitiess())
                {
                    db.QuizDetails.Add(quizDetail);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #2
0
        public async Task <IActionResult> PutQuizDetail(int id, QuizDetail QuizDetail)
        {
            if (id != QuizDetail.QId)
            {
                return(BadRequest());
            }
            _context.Entry(QuizDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuizDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
        public async Task <ActionResult <QuizDetail> > PostQuizDetail(QuizDetail QuizDetail)
        {
            _context.QuizDetails.Add(QuizDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetQuizDetail", new { id = QuizDetail.QId }, QuizDetail));
        }
 public static List <string> GetActions(this QuizDetail qd)
 {
     return(new List <string> {
         "View"
     });
 }