public void UpdateDesign(LayoutEntity item) { this.Update(item, new Data.DataFilter(new List <string> { "ContainerClass" }).Where("ID", OperatorType.Equal, item.ID)); 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.Delete(m.ID)); } if (item.Html != null) { var layoutHtmlService = new LayoutHtmlService(); layoutHtmlService.Delete(m => m.LayoutId == item.ID); item.Html.Each(m => { m.LayoutId = item.ID; layoutHtmlService.Add(m); }); } }
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) { LayoutHtmlService layoutHtmlService = new LayoutHtmlService(); item.Html.Each(m => { m.LayoutId = item.ID; layoutHtmlService.Add(m); }); } }