Example #1
0
        protected static bool UpdateVocabulary(VocModel Voc)
        {
            var    oldVoc          = Vocabularies.First(c => c.Id == Voc.Id).ToModel();
            int    field           = 0;
            string ColumnsToUpdate = string.Empty;

            CheckFieldUpdate("Words", Voc.Text, oldVoc.Text, ref field, ref ColumnsToUpdate);
            CheckFieldUpdate("Answer", Voc.Answer, oldVoc.Answer, ref field, ref ColumnsToUpdate);
            CheckFieldUpdate("Definition", Voc.Definition, oldVoc.Definition, ref field, ref ColumnsToUpdate);
            CheckFieldUpdate("PtBr", Voc.PtBr, oldVoc.PtBr, ref field, ref ColumnsToUpdate);

            CheckQuestionChanges(Voc, oldVoc, ref field, ref ColumnsToUpdate);

            if (ColumnsToUpdate.IsEmpty())
            {
                return(Errors.ThrowErrorMsg(ErrorType.NullOrEmpty, ColumnsToUpdate));
            }

            string query = string.Format(UpdateSQL, Model.Voc.ToDesc(), ColumnsToUpdate, Voc.Id);

            if (!SendQuery(query))
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        protected static bool InsertVocabulary(VocModel Voc)
        {
            string query = string.Format(InsertSQL + "'{1}', '{2}', {3}, '{4}', '{5}', {6})",
                                         Model.Voc.ToDesc(),
                                         Voc.Text, Voc.Answer,
                                         Null, Null, Voc.Importance, Voc.IsActive);

            if (!SendQuery(query))
            {
                return(false);
            }

            var inserted = GetLast(Model.Voc.ToDesc());

            Vocabularies.Add(inserted.Tables[0].AsEnumerable().
                             Select(GetDatarowVocabulary()).First().ToVM());

            return(true);
        }