public void SaveAnswer(Questions questions, login_table objUserProfile)
        {
            tbl_Txn_Test_Result           objQuest       = new tbl_Txn_Test_Result();
            tbl_Question_Choice           objQuestChoice = new tbl_Question_Choice();
            tbl_Txn_Question_Duration_Map objMap         = new tbl_Txn_Question_Duration_Map();

            using (var objContext = new IPTSE_EXAMEntities())
            {
                using (var dbcxtransaction = objContext.Database.BeginTransaction())
                {
                    try
                    {
                        objQuest.CandidateId      = Convert.ToInt32(objUserProfile.Id);
                        objQuest.CandidateEmailId = objUserProfile.email;
                        objQuest.TestXQId         = questions.Id;
                        objQuest.ChoiceId         = questions.selectedvalue;
                        objQuest.MarkScored       = questions.markScored;
                        var isRight = objContext.tbl_Question_Choice.Where(t => t.Id == questions.selectedvalue).Select(t1 => t1.IsAnswer).ToString();
                        if (isRight == "true")
                        {
                            objQuest.MarkScored = objContext.tbl_Question.Where(t1 => t1.Id == questions.Id).Select(t2 => t2.Points).FirstOrDefault();
                        }
                        objQuest.CreatedBy   = objUserProfile.email;
                        objQuest.CreatedDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        objContext.tbl_Txn_Test_Result.Add(objQuest);
                        objMap.TestXQId       = questions.Id;
                        objMap.AnswerTime_Sec = Convert.ToInt32(60 - Convert.ToInt32(questions.skippedTime.Substring(questions.skippedTime.Length - 2)));
                        //objMap.AnswerTime_Sec = Convert.ToInt32(timeSpend);
                        objMap.CreatedBy   = objUserProfile.email;
                        objMap.CreatedDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        objContext.tbl_Txn_Question_Duration_Map.Add(objMap);
                        objContext.SaveChanges();
                        dbcxtransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
        public void SaveRemaining(Questions quest, UserProfile objUserProfile)
        {
            tbl_Txn_Test_Result           objQuest       = new tbl_Txn_Test_Result();
            tbl_Question_Choice           objQuestChoice = new tbl_Question_Choice();
            tbl_Txn_Question_Duration_Map objMap         = new tbl_Txn_Question_Duration_Map();

            using (var objContext = new IPTSE_EXAMEntities())
            {
                using (var dbcxtransaction = objContext.Database.BeginTransaction())
                {
                    try
                    {
                        objQuest.CandidateId      = objUserProfile.Id;
                        objQuest.CandidateEmailId = objUserProfile.email;
                        objQuest.TestXQId         = quest.Id;
                        objQuest.ChoiceId         = quest.selectedvalue;
                        objQuest.MarkScored       = quest.markScored;
                        var isRight = objContext.tbl_Question_Choice.Where(t => t.Id == quest.selectedvalue).Select(t1 => t1.IsAnswer).ToString();
                        if (isRight == "true")
                        {
                            objQuest.MarkScored = objContext.tbl_Question.Where(t1 => t1.Id == quest.Id).Select(t2 => t2.Points).FirstOrDefault();
                        }
                        objContext.tbl_Txn_Test_Result.Add(objQuest);
                        objMap.TestXQId       = quest.Id;
                        objMap.AnswerTime_Sec = objMap.AnswerTime_Sec = Convert.ToInt32(60 - Convert.ToInt32(quest.skippedTime.Substring(quest.skippedTime.Length - 2)));
                        objContext.tbl_Txn_Question_Duration_Map.Add(objMap);
                        objContext.SaveChanges();
                        dbcxtransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
        public void AddQuestion(Questions in_question)
        {
            using (IPTSE_EXAMEntities db = new IPTSE_EXAMEntities())
            {
                using (var dbcxtransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        tbl_Question          question          = new tbl_Question();
                        tbl_Question_Category question_Category = new tbl_Question_Category();
                        tbl_Question_Choice   question_Choice   = new tbl_Question_Choice();
                        //tbl_Test test = new tbl_Test();
                        tbl_Test_Question_Map test_question_Map = new tbl_Test_Question_Map();

                        question.QuestionText         = in_question.QuestionText;
                        question.IsActive             = in_question.IsActive;
                        question.Points               = in_question.Points;
                        question.QuestionCategoryId   = (int)in_question.QuestionCategoryId;
                        question.QuestionDifficultyId = in_question.QuestionDifficultyId;
                        question.CreatedBy            = "Admin";
                        question.CreatedDate          = DateTime.Now;
                        question.Points               = 1;
                        db.tbl_Question.Add(question);
                        db.SaveChanges();
                        //question.Id

                        db.tbl_Test_Question_Map.Add(new tbl_Test_Question_Map
                        {
                            TestId      = in_question.TestId,
                            QuestionId  = question.Id,
                            IsActive    = in_question.IsActive,
                            CreatedBy   = "Admin",
                            CreatedDate = DateTime.Now
                        });

                        foreach (QuestionsChoice item in in_question.questionsChoice)
                        {
                            db.tbl_Question_Choice.Add(new tbl_Question_Choice
                            {
                                ChoiceText  = item.ChoiceText,
                                IsActive    = item.IsActive,
                                IsAnswer    = item.IsAnswer,
                                Question_Id = question.Id,
                                CreatedBy   = "Admin",
                                CreatedDate = DateTime.Now
                                              //,tbl_Question = question
                            });
                        }
                        db.SaveChanges();
                        dbcxtransaction.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        dbcxtransaction.Rollback();
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        dbcxtransaction.Rollback();
                        throw ex;
                    }
                }
            }
        }