Exemplo n.º 1
0
 //Get Individual Quiz detail
 public quizModel GetQuizById(int quizId)
 {
     using (myProjectEntities context = new myProjectEntities())
     {
         tblQuizDetail pro = context.tblQuizDetails.Where(q => q.PK_Quiz_id == quizId).FirstOrDefault();
         Mapper.CreateMap <tblQuizDetail, quizModel>();
         quizModel result = Mapper.Map <tblQuizDetail, quizModel>(pro);
         return(result);
     }
 }
Exemplo n.º 2
0
        //Update existing Quiz + Change the status to delete the quiz
        public bool UpdateQuiz(quizModel quizData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <quizModel, tblQuizDetail>();
                tblQuizDetail s = Mapper.Map <quizModel, tblQuizDetail>(quizData);
                context.Entry(s).State = EntityState.Modified;
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = true;
                }
                return(result);
            }
        }
Exemplo n.º 3
0
        //Create Quiz
        public int CreateQuiz(quizModel quizData)
        {
            int result = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                quizData.quiz_update = System.DateTime.Now; // Last Update or Created Date Time
                quizData.quiz_status = 1;                   // Live coming Quiz

                Mapper.CreateMap <quizModel, tblQuizDetail>();
                tblQuizDetail newQuiz = Mapper.Map <quizModel, tblQuizDetail>(quizData);


                context.tblQuizDetails.Add(newQuiz); //Execute the add function
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = newQuiz.PK_Quiz_id;     //set return to true
                }
            }
            return(result);
        }