예제 #1
0
파일: Score.cs 프로젝트: nbl852003/iudico
        protected int SetVariable(string name, string value)
        {
            if (elements[name].Write == false)
            {
                throw new Exception(Translations.Score_SetValue_Requested_variable_is_read_only);
            }

            List <TblVarsScore> list = ServerModel.DB.Query <TblVarsScore>(
                new AndCondition(
                    new CompareCondition <int>(
                        DataObject.Schema.LearnerSessionRef,
                        new ValueCondition <int>(LearnerSessionId), COMPARE_KIND.EQUAL),
                    new CompareCondition <string>(
                        DataObject.Schema.Name,
                        new ValueCondition <string>(name), COMPARE_KIND.EQUAL)));

            if (list.Count > 0)
            {
                list[0].Value = value;
                ServerModel.DB.Update <TblVarsScore>(list[0]);

                return(list[0].ID);
            }
            else
            {
                TblVarsScore lsv = new TblVarsScore
                {
                    LearnerSessionRef = LearnerSessionId,
                    Name  = name,
                    Value = value
                };

                return(ServerModel.DB.Insert <TblVarsScore>(lsv));
            }
        }
예제 #2
0
파일: Score.cs 프로젝트: supermuk/iudico
        protected int SetVariable(string name, string value)
        {
             if (elements[name].Write == false)
            {
                throw new Exception(Translations.Score_SetValue_Requested_variable_is_read_only);
            }

             List<TblVarsScore> list = ServerModel.DB.Query<TblVarsScore>(
                        new AndCondition(
                            new CompareCondition<int>(
                                DataObject.Schema.LearnerSessionRef,
                                new ValueCondition<int>(LearnerSessionId), COMPARE_KIND.EQUAL),
                            new CompareCondition<string>(
                                DataObject.Schema.Name,
                                new ValueCondition<string>(name), COMPARE_KIND.EQUAL)));

            if (list.Count > 0)
            {
                list[0].Value = value;
                ServerModel.DB.Update<TblVarsScore>(list[0]);

                return list[0].ID;
            }
            else
            {
                TblVarsScore lsv = new TblVarsScore
                {
                    LearnerSessionRef = LearnerSessionId,
                    Name = name,
                    Value = value
                };

                return ServerModel.DB.Insert<TblVarsScore>(lsv);
            }
        }