Пример #1
0
        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);
        }
Пример #2
0
        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);
                });
                zones.Each(m =>
                {
                    var changeZone = item.Zones.FirstOrDefault(z => z.ID == m.ID);
                    if (changeZone != null)
                    {
                        m.LayoutId = item.ID;
                        m.Title    = changeZone.Title;
                        m.ZoneName = changeZone.ZoneName;
                        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);
                });
            }
        }