Ejemplo n.º 1
0
        public void SaveQuestionType(SaveQuestionType QuestionType)
        {
            DataTable dtQuestionType = null;
            DataRow   drNew          = null;

            try
            {
                LoadXML();
                dtQuestionType = oeEntity.Tables[EntityConstents.TBL_QUESTIONTYPE];

                if (QuestionType.EntityState == EntityOperationalState.New)
                {
                    drNew = dtQuestionType.NewRow();
                    drNew[EntityConstents.COL_QUESTIONTYPE_ID] = Guid.NewGuid().ToString();
                    dtQuestionType.Rows.Add(drNew);
                }
                else
                {
                    drNew = dtQuestionType.AsEnumerable().Where(ans => ans.Field <string>("ID") == QuestionType.ID).SingleOrDefault();
                }


                drNew[EntityConstents.COL_QUESTIONTYPE_CODE]    = QuestionType.Code;
                drNew[EntityConstents.COL_QUESTIONTYPE_DESC]    = QuestionType.Description;
                drNew[EntityConstents.COL_QUESTIONTYPE_TYPE]    = GetQTypeValue(QuestionType.Type);
                drNew[EntityConstents.COL_QUESTIONTYPE_FK_TYPE] = QuestionType.FkQuestionTypeID;

                saveXML(oeEntity);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public int Save(SaveQuestionType savableObj)
        {
            QuestionTypeDal dal = new QuestionTypeDal()
            {
                Id   = savableObj.Id,
                Name = savableObj.Name
            };

            if (savableObj.Id == default(int))
            {
                return(_rep.Insert(dal));
            }

            _rep.Update(dal);
            return(0);
        }
Ejemplo n.º 3
0
        public ResponseData <int> SaveQuestionType(SaveQuestionType saveQuestionType)
        {
            ResponseData <int> resp = new ResponseData <int>();

            QuestionTypeFacade facade = new QuestionTypeFacade();

            try
            {
                resp.Data = facade.Save(saveQuestionType);
            }
            catch (Exception ex)
            {
                ExceptionHandlerFactory.Factory.GetResponseExceptionHandler(resp).Handle(ex);
            }
            return(resp);
        }
Ejemplo n.º 4
0
        private void SaveQuestionTypeForQuestion(SaveQuestion saveQuestion)
        {
            string modeID      = string.Empty;
            string groupTypeID = string.Empty;
            string topicTypeID = string.Empty;
            MasterDataFunctions      mDataFunc        = null;
            SaveQuestionType         saveQuestionType = null;
            SaveQuestionTypes        questionType     = null;
            List <SaveQuestionTypes> questionTypeColl = null;

            try
            {
                groupTypeID = ((KeyValuePair <string, string>)cbGroupType.SelectedItem).Key;
                topicTypeID = ((KeyValuePair <string, string>)cbTopicType.SelectedItem).Key;
                modeID      = ((KeyValuePair <string, string>)cbQuestionMode.SelectedItem).Key;

                mDataFunc        = new MasterDataFunctions();
                saveQuestionType = new SaveQuestionType();
                questionType     = new SaveQuestionTypes();
                questionTypeColl = new List <SaveQuestionTypes>();

                questionType.Type = QuestionTypes.Topic;
                questionType.ID   = topicTypeID;
                questionTypeColl.Add(questionType);
                questionType      = new SaveQuestionTypes();
                questionType.Type = QuestionTypes.Mode;
                questionType.ID   = modeID;
                questionTypeColl.Add(questionType);

                saveQuestionType.QuestionID    = saveQuestion.QuestionID;
                saveQuestionType.Code          = string.Empty;
                saveQuestionType.Description   = string.Empty;
                saveQuestionType.Type          = QuestionTypes.Question;
                saveQuestionType.QuestionTypes = questionTypeColl;

                mDataFunc.SaveQuestionTypeRelation(saveQuestionType);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public void SaveQuestionTypeRelation(SaveQuestionType QuestionType)
        {
            DataRow drNew = null;

            DataRow[] drNewColl          = null;
            DataTable dtQuestionRelation = null;

            try
            {
                LoadXML();
                dtQuestionRelation = oeEntity.Tables[EntityConstents.TBL_QUESTIONS_REL];

                if (QuestionType.EntityState == EntityOperationalState.Update)
                {
                    drNewColl = dtQuestionRelation.AsEnumerable().Where(ans => ans.Field <string>("ID") == QuestionType.ID).ToArray();
                    for (int cnt = drNewColl.Count() - 1; cnt >= 0; cnt--)
                    {
                        dtQuestionRelation.Rows.Remove(drNewColl[cnt]);
                    }
                }

                foreach (SaveQuestionTypes sqType in QuestionType.QuestionTypes)
                {
                    drNew = dtQuestionRelation.NewRow();
                    drNew[EntityConstents.COL_QUESTIONS_REL_ID]     = Guid.NewGuid().ToString();
                    drNew[EntityConstents.COL_QUESTIONS_REL_QUSID]  = QuestionType.QuestionID;
                    drNew[EntityConstents.COL_QUESTIONS_REL_TYPEID] = sqType.ID;

                    dtQuestionRelation.Rows.Add(drNew);
                }
                saveXML(oeEntity);
            }
            catch
            {
                throw;
            }
        }