public void CreatePluggContent(PluggContent t) { using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository<PluggContent>(); rep.Insert(t); } }
public void CreatePluggContent(PluggContent t) { using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <PluggContent>(); rep.Insert(t); } }
public void DeletePluggContent(PluggContent pc) { using (IDataContext db = DataContext.Instance()) { var rep = db.GetRepository <PluggContent>(); rep.Delete(pc); } }
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; } }
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); }
public void CreatePluggContent(PluggContent plugcontent) { rep.CreatePluggContent(plugcontent); }
public void UpdatePluggContent(PluggContent pc) { rep.UpdatePluggContent(pc); }
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; } }
//public IEnumerable<Plugg> GetPluggsInCourse(int courseId) //{ // return rep.GetPluggsInCourse(courseId); //} #endregion #region PluggContent public void CreatePluggContent(PluggContent plugcontent) { rep.CreatePluggContent(plugcontent); }
public void UpdatePluggContent(PluggContent pc) { using (IDataContext db = DataContext.Instance()) { var rep = db.GetRepository<PluggContent>(); rep.Update(pc); } }