public void DeletePlugg(Plugg p) { // Todo: Don't delete Plugg if: It has comments or ratings, Its included in a course. // Todo: Soft delete of Plugg if (p == null) { throw new Exception("Cannot delete: Plugg not initialized"); return; } TabController tabController = new TabController(); TabInfo getTab = tabController.GetTab(p.TabId); if (getTab != null) { DNNHelper h = new DNNHelper(); h.DeleteTab(getTab); } rep.DeleteAllPhTextForItem(p.PluggId, (int)ETextItemType.PluggTitle); rep.DeleteAllPhTextForItem(p.PluggId, (int)ETextItemType.PluggHtml); rep.DeleteAllLatexForItem(p.PluggId, (int)ELatexType.Plugg); rep.DeletePlugg(p); }
public void CreatePlugg(Plugg t) { using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository<Plugg>(); rep.Insert(t); } }
public void DeletePlugg(Plugg plug) { using (IDataContext db = DataContext.Instance()) { var rep = db.GetRepository <Plugg>(); rep.Delete(plug); } }
public void CreatePlugg(Plugg t) { using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository <Plugg>(); rep.Insert(t); } }
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 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 PluggContainer() { ThePlugg = new Plugg(); }
public void UpdatePlugg(Plugg plug) { using (IDataContext db = DataContext.Instance()) { var rep = db.GetRepository<Plugg>(); rep.Update(plug); } }