private void UpdateInfoStatic(TemplateApiModel model, IFormCollection form) { var item = _templateDetailsService.CreateQuery().Find(o => o.IsDynamic == false && o.IsBody == false && o.PartialID == model.PartialID && o.TemplateID == model.Record)?.SingleOrDefault(); if (item == null) { item = new SysTemplateDetailEntity() { IsBody = false, IsDynamic = false, CModule = model.CModule, PartialID = model.PartialID, LayoutName = model.LayoutName, TemplateID = model.Record, TypeView = model.TypeView, ParentID = string.Empty, PartialView = model.PartialView }; _templateDetailsService.Add(item); } string detailsTemplateID = item.ID; foreach (var key in form.Keys) { if (model.GetType().GetMember(key).Count() > 0) { continue; } else { var itemProperties = _propertyService.CreateQuery().Find(o => o.TemplateDetailID == detailsTemplateID && o.Name == key && o.PartialID == model.PartialID)?.SingleOrDefault(); if (itemProperties == null) { itemProperties = new SysTemplatePropertyEntity() { PartialID = item.PartialID, Name = key, TemplateDetailID = detailsTemplateID }; } var data = form[key]; if (!string.IsNullOrEmpty(data)) { itemProperties.Value = data; _propertyService.Add(itemProperties); } } } }
private void AddNewItemDynamic(TemplateApiModel model) { if (model.CModule.ToLower() == "renderbody") { model.IsBody = true; } var item = new SysTemplateDetailEntity() { CModule = model.CModule, IsBody = model.IsBody, LayoutName = model.LayoutName + "(" + model.Name + ")", TypeView = model.TypeView, TemplateID = model.Record, IsDynamic = true, ParentID = model.ParrentLayout, PartialID = Guid.NewGuid().ToString() }; _templateDetailsService.Add(item); }
private LayoutModel ProccessDynamicLayout(SysTemplateDetailEntity dItem) { LayoutModel dLI = new LayoutModel { LayoutName = dItem.LayoutName, CModule = dItem.CModule, PartialID = dItem.PartialID, ParrentLayout = dItem.ParentID, IsDynamic = true, IsBody = dItem.IsBody, PartialView = dItem.PartialView, TypeView = dItem.TypeView, Order = dItem.Order }; if (!dItem.IsBody) { var itemCtrl = _menu.GetControl.SingleOrDefault(o => o.FullName.ToLower() == dItem.CModule.ToLower()); if (itemCtrl == null) { itemCtrl = new CModule() { Code = "Static", FullName = "", Name = "No Exist", Properties = null }; } var properties = itemCtrl.Properties; var property = _propertyService.Find(true, o => o.TemplateDetailID == dItem.ID)?.ToList(); if (property != null && properties != null) { List <ProperyCModule> properyCs = new List <ProperyCModule>(); string _continue = ""; for (int z = 0; z < properties.Count; z++) { var itemPro = properties[z]; ProperyCModule properyC = new ProperyCModule() { Key = itemPro.Key, Name = itemPro.Name, Type = itemPro.Type, Value = itemPro.Value }; foreach (var itemzPRo in property) { if (_continue != "" && _continue == itemzPRo.Name) { continue; } if (itemPro.Key == itemzPRo.Name) { properyC.Value = itemzPRo.Value; _continue = itemzPRo.Name; break; } } properyCs.Add(properyC); } dLI.Properties = properyCs; } } return(dLI); }