Exemplo n.º 1
0
        /// <summary>
        /// Deletes From Junction Table. Removes a Category from a Question.
        /// </summary>
        /// <param name="Category"></param>
        /// <param name="ExamQID"></param>
        public void DeleteQuestionCategory(String Category, String ExamQID)
        {
            var Categoreis = db.Categories.Where(c => c.Categories_Name == Category);

            if (Categoreis.Count() > 0)
            {
                var QuestionID = db.ExamQuestion.Where(c => c.ExamQuestionID == ExamQID);
                if (QuestionID.Count() > 0)
                {
                    EAD.ExamQuestion_Categories temp = new EAD.ExamQuestion_Categories();
                    temp.Categories_ID   = Categoreis.First().Categories_ID;
                    temp.ExamQuestion_ID = db.ExamQuestion.First(s => s.ExamQuestionID == ExamQID).PKID;
                    db.ExamQuestion_Categories.Remove(db.ExamQuestion_Categories.Where(s => s.Categories_ID == temp.Categories_ID && s.ExamQuestion_ID == temp.ExamQuestion_ID).First());//.Where(s => s.Categories_ID == temp.Categories_ID && s.ExamQuestion_ID == temp.ExamQuestion_ID).;
                    NLogConfig.logger.Log(new LogEventInfo(LogLevel.Info, "WFCLogger", temp.Categories_ID.ToString()));
                    NLogConfig.logger.Log(new LogEventInfo(LogLevel.Info, "WFCLogger", temp.ExamQuestion_ID.ToString()));
                }
            }
            db.SaveChanges();
        }
Exemplo n.º 2
0
        /*  public void spAddQuestionCategories(String Categories, int PKID)
         * {
         *    int result = 0;
         *    db.spAddQuestionCategories(Categories, PKID, result);
         *
         * }*/
        /// <summary>
        /// Adds a Categorie to an exam Question.
        /// </summary>
        /// <param name="Categories"></param>
        /// <param name="ExamQuestionID"></param>
        public void AddQuestionCategories(String Categories, String ExamQuestionID)
        {
            var Categoreis = db.Categories.Where(c => c.Categories_Name == Categories);

            if (Categoreis.Count() > 0)
            {
                var QuestionID = db.ExamQuestion.Where(c => c.ExamQuestionID == ExamQuestionID);
                if (QuestionID.Count() > 0)
                {
                    EAD.ExamQuestion_Categories temp = new EAD.ExamQuestion_Categories();
                    temp.Categories_ID   = Categoreis.First().Categories_ID;
                    temp.ExamQuestion_ID = db.ExamQuestion.First(s => s.ExamQuestionID == ExamQuestionID).PKID;
                    db.ExamQuestion_Categories.Add(temp);
                    NLogConfig.logger.Log(new LogEventInfo(LogLevel.Info, "WFCLogger", temp.Categories_ID.ToString()));
                    //Logs the List of IDs for the Categoires attached to the Exam Question

                    NLogConfig.logger.Log(new LogEventInfo(LogLevel.Info, "WFCLogger", temp.ExamQuestion_ID.ToString()));
                    //Logs the Exam Question ID of which Exam Question working with
                }
            }
            db.SaveChanges(); //Saves Changes to the Database
        }