public void UpdateDesign(LayoutEntity item) { CurrentDbSet.Attach(item); DbContext.Entry(item).Property(m => m.ContainerClass).IsModified = true; DbContext.SaveChanges(); if (item.Zones != null) { var zones = ZoneService.Get(m => m.LayoutId == item.ID); item.Zones.Where(m => zones.All(n => n.ID != m.ID)).Each(m => { m.LayoutId = item.ID; ZoneService.Add(m); }); item.Zones.Where(m => zones.Any(n => n.ID == m.ID)).Each(m => { m.LayoutId = item.ID; ZoneService.Update(m); }); zones.Where(m => item.Zones.All(n => n.ID != m.ID)).Each(m => ZoneService.Remove(m.ID)); } if (item.Html != null) { LayoutHtmlService.Remove(m => m.LayoutId == item.ID); item.Html.Each(m => { m.LayoutId = item.ID; LayoutHtmlService.Add(m); }); } }
public override ServiceResult <LayoutEntity> Add(LayoutEntity item) { item.ID = Guid.NewGuid().ToString("N"); var result = base.Add(item); if (result.HasViolation) { return(result); } if (item.Zones != null) { item.Zones.Each(m => { m.LayoutId = item.ID; ZoneService.Add(m); }); } if (item.Html != null) { item.Html.Each(m => { m.LayoutId = item.ID; LayoutHtmlService.Add(m); }); } return(result); }
public IList <LayoutEntity> GetWithFull() { var layouts = Get().ToList(); var zones = ZoneService.Get().ToList(); var htmls = LayoutHtmlService.Get().ToList(); foreach (var item in layouts) { item.Zones = new ZoneCollection(); zones.Where(m => m.LayoutId == item.ID).Each(item.Zones.Add); item.Html = new LayoutHtmlCollection(); htmls.Where(m => m.LayoutId == item.ID).Each(item.Html.Add); } return(layouts); }
public override void Remove(LayoutEntity item, bool saveImmediately = true) { LayoutHtmlService.Remove(m => m.LayoutId == item.ID); ZoneService.Remove(m => m.LayoutId == item.ID); PageService.Remove(m => m.LayoutId == item.ID); var widgets = WidgetService.Get(m => m.LayoutID == item.ID); widgets.Each(m => { using (var widgetService = WidgetActivator.Create(m)) { widgetService.DeleteWidget(m.ID); } }); MarkChanged(item.ID); base.Remove(item, saveImmediately); }
public override void Remove(LayoutEntity item) { LayoutHtmlService.Remove(m => m.LayoutId == item.ID); ZoneService.Remove(m => m.LayoutId == item.ID); PageService.Remove(m => m.LayoutId == item.ID); var widgets = WidgetService.Get(m => m.LayoutID == item.ID); widgets.Each(m => { using (var widgetService = m.CreateServiceInstance(ApplicationContext.ServiceLocator)) { widgetService.DeleteWidget(m.ID); } }); MarkChanged(item.ID); base.Remove(item); }
public override void RemoveRange(params LayoutEntity[] items) { items.Each(layout => { LayoutHtmlService.Remove(m => m.LayoutId == layout.ID); ZoneService.Remove(m => m.LayoutId == layout.ID); PageService.Remove(m => m.LayoutId == layout.ID); var widgets = WidgetService.Get(m => m.LayoutID == layout.ID); widgets.Each(m => { using (var widgetService = WidgetActivator.Create(m)) { widgetService.DeleteWidget(m.ID); } }); MarkChanged(layout.ID); }); base.RemoveRange(items); }
public override void Remove(Expression <Func <LayoutEntity, bool> > filter) { Get(filter).Each(layout => { LayoutHtmlService.Remove(m => m.LayoutId == layout.ID); ZoneService.Remove(m => m.LayoutId == layout.ID); PageService.Remove(m => m.LayoutId == layout.ID); var widgets = WidgetService.Get(m => m.LayoutID == layout.ID); widgets.Each(m => { using (var widgetService = WidgetActivator.Create(m)) { widgetService.DeleteWidget(m.ID); } }); MarkChanged(layout.ID); }); base.Remove(filter); }
public override void Add(LayoutEntity item) { item.ID = Guid.NewGuid().ToString("N"); base.Add(item); if (item.Zones != null) { item.Zones.Each(m => { m.LayoutId = item.ID; ZoneService.Add(m); }); } if (item.Html != null) { item.Html.Each(m => { m.LayoutId = item.ID; LayoutHtmlService.Add(m); }); } }
public override LayoutEntity Get(params object[] primaryKeys) { //var layout = DataArchivedService.Get(GenerateKey(primaryKeys), () => //{ LayoutEntity entity = base.Get(primaryKeys); if (entity == null) { return(null); } IEnumerable <ZoneEntity> zones = ZoneService.GetZonesByLayoutId(entity.ID); entity.Zones = new ZoneCollection(); zones.Each(entity.Zones.Add); IEnumerable <LayoutHtml> htmls = LayoutHtmlService.GetByLayoutID(entity.ID); entity.Html = new LayoutHtmlCollection(); htmls.Each(entity.Html.Add); return(entity); //}); //return layout; }