Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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);
            }
        }