Ejemplo n.º 1
0
 public void DeleteLatexText(PHLatex p)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository <PHLatex>();
         rep.Delete(p);
     }
 }
Ejemplo n.º 2
0
 public void CreateLatexText(PHLatex p)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<PHLatex>();
         rep.Insert(p);
     }
 }
Ejemplo n.º 3
0
 public void CreateLatexText(PHLatex p)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <PHLatex>();
         rep.Insert(p);
     }
 }
Ejemplo n.º 4
0
        public void LoadLatexText()
        {
            if (ThePlugg == null || ThePlugg.PluggId == 0 || CultureCode == null)
            {
                throw new Exception("Cannot load Latex. Need PluggId and CultureCode");
            }
            BaseRepository rep = new BaseRepository();

            TheLatex = rep.GetLatexText(CultureCode, ThePlugg.PluggId, (int)ELatexType.Plugg);
        }
Ejemplo n.º 5
0
        public PHLatex GetLatexText(string cultureCode, int itemId, int itemType)
        {
            IEnumerable <PHLatex> txt;
            PHLatex theText = null;

            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <PHLatex>();
                txt = rep.Find("WHERE CultureCode = @0 AND ItemId = @1 AND ItemType = @2", cultureCode, itemId, itemType);
            }

            if (txt.Any())
            {
                theText = txt.First(); //Can only be at most one. PetaPoco does not handle composite key
            }
            return(theText);
        }
Ejemplo n.º 6
0
        public void SaveLatexText(PHLatex t)
        {
            if (t.Text == null || t.ItemId == 0 || t.ItemType == ELatexType.NotSet || t.CultureCode == null || t.CcStatus == ECCStatus.NotSet || t.CreatedByUserId == 0)
            {
                throw new Exception("Cannot save Latex - need Text, ItemId, ItemType, CultureCode, CreatedByUserId and CcStatus");
            }

            if (t.ModifiedByUserId == 0)
            {
                t.ModifiedByUserId = t.CreatedByUserId;
            }
            t.ModifiedOnDate = DateTime.Now;
            t.CurrentVersion = true;
            bool isVersioned = (t.ItemType == ELatexType.Plugg || t.ItemType == ELatexType.Course);

            if (isVersioned)
            {
                var prevText = rep.GetLatexText(t.CultureCode, t.ItemId, (int)t.ItemType);
                if (prevText == null)
                {
                    t.Version = 1;
                }
                else
                {
                    t.Version = prevText.Version++;
                    prevText.CurrentVersion = false;
                    rep.UpdateLatexText(prevText);
                }
                t.CreatedOnDate = DateTime.Now;
                rep.CreateLatexText(t);
            }
            else
            {
                t.Version = 0;
                if (t.LatexId == 0)
                {
                    t.CreatedOnDate = DateTime.Now;
                    rep.CreateLatexText(t);
                }
                else
                {
                    rep.UpdateLatexText(t);
                }
            }
        }
Ejemplo n.º 7
0
        //translates t into culture code cc
        public void GoogleTranslate(PHLatex t, string cc)
        {
            if (t.CultureCode == cc)
            {
                throw new Exception("Cannot translate text to the same language");
            }

            PHLatex currentText = rep.GetLatexText(cc, t.ItemId, (int)t.ItemType);

            if (currentText == null)
            {
                //Todo: Translate. For now: same
                t.CultureCode = cc;
                //t.Text = (Translation of t.Text from t.CultureCode into cc)
                rep.CreateLatexText(t);
            }
            else
            {
                currentText.Text = t.Text;
                rep.UpdateLatexText(currentText);
            }
        }
Ejemplo n.º 8
0
        public void SaveLatexText(PHLatex t)
        {
            if (t.Text == null || t.ItemId == 0 || t.ItemType == ELatexType.NotSet || t.CultureCode == null || t.CcStatus == ECCStatus.NotSet || t.CreatedByUserId == 0)
                throw new Exception("Cannot save Latex - need Text, ItemId, ItemType, CultureCode, CreatedByUserId and CcStatus");

            if (t.ModifiedByUserId == 0)
                t.ModifiedByUserId = t.CreatedByUserId;
            t.ModifiedOnDate = DateTime.Now;
            t.CurrentVersion = true;
            bool isVersioned = (t.ItemType == ELatexType.Plugg || t.ItemType == ELatexType.Course);

            if (isVersioned)
            {
                var prevText = rep.GetLatexText(t.CultureCode, t.ItemId, (int)t.ItemType);
                if (prevText == null)
                {
                    t.Version = 1;
                }
                else
                {
                    t.Version = prevText.Version++;
                    prevText.CurrentVersion = false;
                    rep.UpdateLatexText(prevText);
                }
                t.CreatedOnDate = DateTime.Now;
                rep.CreateLatexText(t);
            }
            else
            {
                t.Version = 0;
                if (t.LatexId == 0)
                {
                    t.CreatedOnDate = DateTime.Now;
                    rep.CreateLatexText(t);
                }
                else
                    rep.UpdateLatexText(t);
            }
        }
Ejemplo n.º 9
0
        //translates t into culture code cc
        public void GoogleTranslate(PHLatex t, string cc)
        {
            if (t.CultureCode == cc)
                throw new Exception("Cannot translate text to the same language");

            PHLatex currentText = rep.GetLatexText(cc, t.ItemId, (int)t.ItemType);

            if (currentText == null)
            {
                //Todo: Translate. For now: same
                t.CultureCode = cc;
                //t.Text = (Translation of t.Text from t.CultureCode into cc)
                rep.CreateLatexText(t);
            }
            else
            {
                currentText.Text = t.Text;
                rep.UpdateLatexText(currentText);
            }
        }
Ejemplo n.º 10
0
 public void SetLatexText(string htmlText)
 {
     TheLatex = new PHLatex(htmlText, ThePlugg.CreatedInCultureCode, ELatexType.Plugg);
 }
Ejemplo n.º 11
0
 public void UpdateLatexText(PHLatex p)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository<PHLatex>();
         rep.Update(p);
     }
 }
Ejemplo n.º 12
0
 public void SetLatexText(string htmlText)
 {
     TheLatex = new PHLatex(htmlText, ThePlugg.CreatedInCultureCode, ELatexType.Plugg);
 }
Ejemplo n.º 13
0
 public void LoadLatexText()
 {
     if (ThePlugg == null || ThePlugg.PluggId == 0 || CultureCode == null)
         throw new Exception("Cannot load Latex. Need PluggId and CultureCode");
     BaseRepository rep = new BaseRepository();
     TheLatex = rep.GetLatexText(CultureCode, ThePlugg.PluggId, (int)ELatexType.Plugg);
 }