Exemplo n.º 1
0
 public void CreatePluggContent(PluggContent t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<PluggContent>();
         rep.Insert(t);
     }
 }
Exemplo n.º 2
0
 public void CreatePluggContent(PluggContent t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <PluggContent>();
         rep.Insert(t);
     }
 }
Exemplo n.º 3
0
 public void DeletePluggContent(PluggContent pc)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository <PluggContent>();
         rep.Delete(pc);
     }
 }
Exemplo n.º 4
0
        public void UpdatePlugg(Plugg p, PluggContent pc)
        {
            //For restore if something goes wrong
            Plugg oldP = GetPlugg(p.PluggId);
            IEnumerable <PluggContent> oldPCs = GetAllContentInPlugg(p.PluggId);

            rep.UpdatePlugg(p); //No repair necessary if this fails

            //For now, remove all PluggContent and recreate in all languages from pc. Fix this when we can deal with translations
            try
            {
                foreach (PluggContent pcDelete in oldPCs)
                {
                    rep.DeletePluggContent(pcDelete);
                }

                pc.PluggId = p.PluggId;
                if (pc.LatexText != null)
                {
                    LatexToMathMLConverter myConverter = new LatexToMathMLConverter(pc.LatexText);
                    myConverter.Convert();
                    pc.LatexTextInHtml = myConverter.HTMLOutput;
                }

                LocaleController lc = new LocaleController();
                var locales         = lc.GetLocales(PortalID);
                foreach (var locale in locales)
                {
                    pc.CultureCode = locale.Key;
                    rep.CreatePluggContent(pc);
                }
            }
            catch (Exception)
            {
                //recreate old Plugg/PluggContent before rethrow
                var pcs = GetAllContentInPlugg(p.PluggId);
                foreach (PluggContent pcDelete in pcs)
                {
                    rep.DeletePluggContent(pcDelete);
                }
                rep.DeletePlugg(p);

                rep.CreatePlugg(oldP);
                foreach (PluggContent oldPC in oldPCs)
                {
                    rep.CreatePluggContent(oldPC);
                }
                throw;
            }
        }
Exemplo n.º 5
0
        public PluggContent GetPluggContent(int pluggId, string cultureCode)
        {
            PluggContent ThePC = null;
            IEnumerable <PluggContent> pcs;

            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <PluggContent>();
                pcs = rep.Find("Where PluggId = @0 AND CultureCode = @1", pluggId, cultureCode);
            }
            if (pcs.Any())
            {
                ThePC = pcs.First();  //There can be only one. PetaPoco does not handle composite key
            }
            return(ThePC);
        }
Exemplo n.º 6
0
 public void CreatePluggContent(PluggContent plugcontent)
 {
     rep.CreatePluggContent(plugcontent);
 }
Exemplo n.º 7
0
 public void UpdatePluggContent(PluggContent pc)
 {
     rep.UpdatePluggContent(pc);
 }
Exemplo n.º 8
0
        public void UpdatePlugg(Plugg p, PluggContent pc)
        {
            //For restore if something goes wrong
            Plugg oldP = GetPlugg(p.PluggId);
            IEnumerable<PluggContent> oldPCs = GetAllContentInPlugg(p.PluggId);

            rep.UpdatePlugg(p); //No repair necessary if this fails

            //For now, remove all PluggContent and recreate in all languages from pc. Fix this when we can deal with translations
            try
            {
                foreach (PluggContent pcDelete in oldPCs)
                {
                    rep.DeletePluggContent(pcDelete);
                }

                pc.PluggId = p.PluggId;
                if (pc.LatexText != null)
                {
                    LatexToMathMLConverter myConverter = new LatexToMathMLConverter(pc.LatexText);
                    myConverter.Convert();
                    pc.LatexTextInHtml = myConverter.HTMLOutput;
                }

                LocaleController lc = new LocaleController();
                var locales = lc.GetLocales(PortalID);
                foreach (var locale in locales)
                {
                    pc.CultureCode = locale.Key;
                    rep.CreatePluggContent(pc);
                }
            }
            catch (Exception)
            {
                //recreate old Plugg/PluggContent before rethrow
                var pcs = GetAllContentInPlugg(p.PluggId);
                foreach (PluggContent pcDelete in pcs)
                {
                    rep.DeletePluggContent(pcDelete);
                }
                rep.DeletePlugg(p);

                rep.CreatePlugg(oldP);
                foreach (PluggContent oldPC in oldPCs)
                    rep.CreatePluggContent(oldPC);
                throw;
            }
        }
Exemplo n.º 9
0
 public void UpdatePluggContent(PluggContent pc)
 {
     rep.UpdatePluggContent(pc);
 }
Exemplo n.º 10
0
        //public IEnumerable<Plugg> GetPluggsInCourse(int courseId)
        //{
        //    return rep.GetPluggsInCourse(courseId);
        //}

        #endregion

        #region PluggContent

        public void CreatePluggContent(PluggContent plugcontent)
        {
            rep.CreatePluggContent(plugcontent);
        }
Exemplo n.º 11
0
 public void UpdatePluggContent(PluggContent pc)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository<PluggContent>();
         rep.Update(pc);
     }
 }