public override void ExecuteQuery([FromBody] UIApplet model) { base.ExecuteQuery(model); string searchSpecification = ""; List <object> searchSpecArgs = new List <object>(); if (!string.IsNullOrWhiteSpace(model.Name)) { searchSpecification += $"Name.ToLower().Contains(@0)"; searchSpecArgs.Add(model.Name.ToLower()); } if (!string.IsNullOrWhiteSpace(model.BusCompName)) { List <Guid?> componentsId = new List <Guid?>(); context.BusinessComponents.Where(n => n.Name.ToLower().Contains(model.BusCompName.ToLower())).ToList().ForEach(component => componentsId.Add(component.Id)); searchSpecArgs.Add(componentsId); searchSpecification = string.IsNullOrWhiteSpace(searchSpecification) ? "@0.Contains(BusCompId)" : $"{searchSpecification} && {"@1.Contains(BusCompId)"}"; } if (!string.IsNullOrWhiteSpace(model.Type)) { searchSpecArgs.Add(model.Type.ToLower()); string typeSearchSpec = $"Type.ToLower().Contains(@{searchSpecArgs.IndexOf(model.Type.ToLower())})"; searchSpecification = string.IsNullOrWhiteSpace(searchSpecification) ? typeSearchSpec : $"{searchSpecification} && {typeSearchSpec}"; } BusinessObjectComponent objectComponent = viewInfo.BOComponents.FirstOrDefault(n => n.Name == "Applet"); ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecification, searchSpecification); ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecArgs, searchSpecArgs.ToArray()); }
public override BUSApplet UIToBusiness(UIApplet UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSApplet businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); // BusComp BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.BusCompName); if (busComp != null) { businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.BusCompName = busComp.Name; } // PhysicalRender PhysicalRender PR = context.PhysicalRenders.FirstOrDefault(n => n.Name == UIEntity.PhysicalRenderName); if (PR != null) { businessEntity.PhysicalRender = PR; businessEntity.PhysicalRenderId = PR.Id; businessEntity.PhysicalRenderName = PR.Name; } businessEntity.Virtual = UIEntity.Virtual; businessEntity.Header = UIEntity.Header; businessEntity.Type = UIEntity.Type; businessEntity.Initflag = UIEntity.InitFlag; businessEntity.DisplayLines = Convert.ToInt32(UIEntity.DisplayLines); businessEntity.EmptyState = UIEntity.EmptyState; return(businessEntity); }
public override UIApplet BusinessToUI(BUSApplet businessEntity) { UIApplet UIEntity = base.BusinessToUI(businessEntity); UIEntity.InitFlag = businessEntity.Initflag; UIEntity.BusCompName = businessEntity.BusCompName; UIEntity.DisplayLines = businessEntity.DisplayLines.ToString(); UIEntity.EmptyState = businessEntity.EmptyState; UIEntity.PhysicalRenderName = businessEntity.PhysicalRenderName; UIEntity.Header = businessEntity.Header; UIEntity.Type = businessEntity.Type; UIEntity.Virtual = businessEntity.Virtual; return(UIEntity); }
public override IEnumerable <ValidationResult> BUSUIValidate(TContext context, BUSApplet businessComponent, UIApplet UIEntity) { List <ValidationResult> result = base.BUSUIValidate(context, businessComponent, UIEntity).ToList(); if (string.IsNullOrWhiteSpace(businessComponent.ErrorMessage)) { if (!string.IsNullOrWhiteSpace(UIEntity.BusCompName) && businessComponent.BusComp == null) { result.Add(new ValidationResult( "Business component with this name not found.", new List <string>() { "BusCompName" })); } if (!string.IsNullOrWhiteSpace(UIEntity.PhysicalRenderName) && businessComponent.PhysicalRender == null) { result.Add(new ValidationResult( "Physical render with this name not found.", new List <string>() { "PhysicalRenderName" })); } } return(result); }
public override IEnumerable <ValidationResult> UIValidate(TContext context, IViewInfo viewInfo, UIApplet UIEntity, bool isNewRecord) { List <ValidationResult> result = base.UIValidate(context, viewInfo, UIEntity, isNewRecord).ToList(); Applet applet = context.Applets.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.Name); if (applet != null && applet.Id != UIEntity.Id) { result.Add(new ValidationResult("Applet with this name is already exists.", new List <string>() { "Name" })); } return(result); }