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 virtual Dictionary <string, object> CopyRecord() { TDataMapping dataMapping = new TDataMapping(); TOutData newRecord = new TOutData(); Dictionary <string, object> result = new Dictionary <string, object>(); try { TDataBUSFactory dataBUSFactory = new TDataBUSFactory(); newRecord = dataMapping.Map(new List <TInData>() { inEntityDBSet.AsNoTracking().FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord(componentName)) }, context).FirstOrDefault(); outEntityDBSet.AsNoTracking().ToList().Add(newRecord); context.Entry(newRecord).State = EntityState.Added; context.SaveChanges(); ComponentsContext <TBusinessComponent> .SetComponentContext(componentName, dataBUSFactory.DataToBusiness(newRecord, context)); ComponentsRecordsInfo.SetSelectedRecord(componentName, newRecord.Id.ToString()); List <string> currentDisplayedRecords = ComponentsRecordsInfo.GetDisplayedRecords(componentName); ComponentsRecordsInfo.SetDisplayedRecords(componentName, new List <string>() { newRecord.Id.ToString() }.Concat(currentDisplayedRecords).ToList()); result["ErrorMessages"] = null; result["NewRecord"] = newRecord; } catch (Exception ex) { result["ErrorMessages"] = Utils.GetErrorsInfo(ex); result["NewRecord"] = null; return(result); } return(result); }
public override BUSJoinSpecification Init(TContext context) { BUSJoinSpecification businessEntity = base.Init(context); BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Component")); Join join = context.Joins .AsNoTracking() .Select(j => new { id = j.Id, table = j.Table, tableId = j.TableId }) .Select(j => new Join { Id = j.id, Table = j.table, TableId = j.tableId }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Join")); businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.Table = join.Table; businessEntity.TableId = join.TableId; return(businessEntity); }
public override BUSDrilldown Init(TContext context) { BUSDrilldown businessEntity = base.Init(context); Applet applet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, busCompId = a.BusCompId, busComp = a.BusComp == null ? null : new { id = a.BusComp.Id, name = a.BusComp.Name } }) .Select(a => new Applet { Id = a.id, BusCompId = a.busCompId, BusComp = a.busComp == null ? null : new BusinessComponent { Id = a.busComp.id, Name = a.busComp.name } }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Applet")); if (applet?.BusComp != null) { businessEntity.SourceBusinessComponent = applet.BusComp; businessEntity.SourceBusinessComponentId = (Guid)applet.BusCompId; } return(businessEntity); }
public virtual ActionResult <object> InitializeScreen([FromBody] RequestScreenModel model) { // Проверка, что такой скрин уже не проинициализирован if (screenInfo.Screen == null || screenInfo.Screen.Name != model.NewScreenName) { // Очистка информации viewInfo.Dispose(); // Инициализация скрина screenInfo.Initialize(model.NewScreenName, model.NewViewName, context); screenInfo.ActionType = ActionType.InitializeScreen; screenInfoUI.Initialize(screenInfo, context); // Восстановление контекста при переходе на экран, который присутствует в хлебных крошках if (ComponentsRecordsInfo.GetCrumbs().FirstOrDefault(i => i.ViewId == screenInfo.CurrentView?.ViewId) != null) { ComponentsRecordsInfo.RestoreContext(new List <View>() { context.Views .Include(bo => bo.BusObject) .ThenInclude(boc => boc.BusObjectComponents) .ThenInclude(bc => bc.BusComp) .FirstOrDefault(i => i.Id == screenInfo.CurrentView.ViewId) }); } } else { screenInfo.ActionType = ActionType.ReloadScreen; } return(Ok(screenInfoUI.Serialize())); }
public override BUSViewItem UIToBusiness(UIViewItem UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSViewItem businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); View view = context.Views .AsNoTracking() .Select(v => new { id = v.Id, name = v.Name, viewItems = v.ViewItems.Select(viewItem => new { id = viewItem.Id, name = viewItem.Name, }) }) .Select(v => new View { Id = v.id, Name = v.name, ViewItems = v.viewItems.Select(viewItem => new ViewItem { Id = viewItem.id, Name = viewItem.name }).ToList() }) .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("View")); if (view == null) { businessEntity.ErrorMessage = "First you need create view."; } else { // Если запись новая и она не уникальна, записывается ошибка ViewItem viewItem = view.ViewItems?.FirstOrDefault(n => n.Name == UIEntity.Name); if (viewInfo.ViewItems != null && viewItem != null && viewItem.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"View item with this name is already exists in view {view.Name}."; } else { businessEntity.View = view; businessEntity.ViewId = view.Id; Applet applet = context.Applets.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.AppletName); if (applet != null) { businessEntity.Applet = applet; businessEntity.AppletId = applet.Id; businessEntity.AppletName = applet.Name; } businessEntity.Autofocus = UIEntity.Autofocus.ToString() == string.Empty || UIEntity.Autofocus; businessEntity.AutofocusRecord = UIEntity.AutofocusRecord.ToString() == string.Empty ? 0 : UIEntity.AutofocusRecord; } } return(businessEntity); }
public override SysAddress UIToBusiness(SysAccount_Addresses_Tile_Applet UIEntity, GSAppContext context, IViewInfo viewInfo, bool NewRecord) { SysAddress businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, NewRecord); businessEntity.AccountId = Guid.Parse(ComponentsRecordsInfo.GetSelectedRecord("Account")); businessEntity.FullAddress = UIEntity.FullAddress; return(businessEntity); }
public override SysDivision UIToBusiness(SysAccount_Divisions_Tile_Applet UIEntity, GSAppContext context, IViewInfo viewInfo, bool NewRecord) { SysDivision businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, NewRecord); businessEntity.AccountId = Guid.Parse(ComponentsRecordsInfo.GetSelectedRecord("Account")); businessEntity.Name = UIEntity.Name; businessEntity.ParentDivisionName = UIEntity.ParentDivisionName; return(businessEntity); }
public override SysInvoice UIToBusiness(SysCreate_Account_Invoice_Popup_Applet UIEntity, GSAppContext context, IViewInfo viewInfo, bool NewRecord) { SysInvoice businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, NewRecord); businessEntity.AccountId = Guid.Parse(ComponentsRecordsInfo.GetSelectedRecord("Account")); businessEntity.BIC = UIEntity.BIC; businessEntity.BankAccount = UIEntity.BankAccount; return(businessEntity); }
public override SysContact UIToBusiness(SysAccount_Contacts_Tile_Applet UIEntity, GSAppContext context, IViewInfo viewInfo, bool NewRecord) { SysContact businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, NewRecord); businessEntity.AccountId = Guid.Parse(ComponentsRecordsInfo.GetSelectedRecord("Account")); businessEntity.WorkNumber = UIEntity.WorkNumber; businessEntity.Email = UIEntity.Email; businessEntity.AccountName = UIEntity.AccountName; return(businessEntity); }
public override SysPosition UIToBusiness(SysCreate_Account_Position_Popup_Applet UIEntity, GSAppContext context, IViewInfo viewInfo, bool NewRecord) { SysPosition businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, NewRecord); businessEntity.AccountId = Guid.Parse(ComponentsRecordsInfo.GetSelectedRecord("Account")); businessEntity.ParentPositionName = UIEntity.ParentPositionName; businessEntity.Name = UIEntity.Name; businessEntity.PrimaryEmployeeFullName = UIEntity.PrimaryEmployeeFullName; return(businessEntity); }
public override SysAddress UIToBusiness(SysCreate_Account_Address_Popup_Applet UIEntity, GSAppContext context, IViewInfo viewInfo, bool NewRecord) { SysAddress businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, NewRecord); businessEntity.AccountId = Guid.Parse(ComponentsRecordsInfo.GetSelectedRecord("Account")); businessEntity.Street = UIEntity.Street; businessEntity.Country = UIEntity.Country; businessEntity.House = UIEntity.House; businessEntity.City = UIEntity.City; return(businessEntity); }
public override void ExecuteQuery([FromBody] UIScreen 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()); } BusinessObjectComponent objectComponent = viewInfo.BOComponents.FirstOrDefault(n => n.Name == "Screen"); ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecification, searchSpecification); ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecArgs, searchSpecArgs.ToArray()); }
public virtual ActionResult <object> UpdateViewInfo([FromBody] RequestViewModel model) { Applet applet = viewInfo.ViewApplets.FirstOrDefault(n => n.Name == model.TargetApplet); viewInfo.ActionType = (ActionType)Enum.Parse(typeof(ActionType), model.ActionType); if (applet != null) { BusinessComponent component = viewInfo.ViewBCs.FirstOrDefault(i => i.Id == applet.BusCompId); // Текущий апплет viewInfo.CurrentApplet = applet; // Текущий контрол viewInfo.CurrentControl = applet.Controls.FirstOrDefault(n => n.Name == model.CurrentControl); viewInfo.CurrentColumn = applet.Columns.FirstOrDefault(n => n.Name == model.CurrentColumn); // При выборе из списка устанавливается выбранная запись if (model.CurrentRecord != null) { viewInfo.CurrentRecord = model.CurrentRecord; ComponentsRecordsInfo.SetSelectedRecord(component.Name, model.CurrentRecord); } } // В процессе работы с попапом if (viewInfo.CurrentPopupApplet != null) { // Текущий контрол на попапе viewInfo.CurrentPopupControl = viewInfo.CurrentPopupApplet?.Controls.FirstOrDefault(n => n.Name == model.CurrentPopupControl); } // Открытие/закрытие попапа if (model.OpenPopup) { viewInfo.AddPopupApplet(context); } if (model.ClosePopup && viewInfo.CurrentPopupApplet != null) { viewInfo.RemovePopupApplet(context); } // В случае отмены создания записи, проставление null в контексте бизнес компоненты апплета if (viewInfo.ActionType == ActionType.UndoRecord) { TBUSFactory busFactory = new TBUSFactory(); busFactory.SetRecord(null, context, viewInfo, viewInfo.CurrentPopupApplet?.BusComp ?? viewInfo.CurrentApplet.BusComp, null); } viewInfoUI.Initialize(context); return(viewInfoUI.Serialize()); }
public override BUSColumnUP UIToBusiness(UIColumnUP UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSColumnUP businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); Column column = context.Columns .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, columnUPs = a.ColumnUPs.Select(columnUP => new { id = columnUP.Id, name = columnUP.Name }) }) .Select(a => new Column { Id = a.id, Name = a.name, ColumnUPs = a.columnUPs.Select(columnUP => new ColumnUP { Id = columnUP.id, Name = columnUP.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Column")); if (column == null) { businessEntity.ErrorMessage = "First you need create column."; } else { // Если запись новая и она не уникальна, записывается ошибка ColumnUP columnUP = column.ColumnUPs.FirstOrDefault(n => n.Name == UIEntity.Name); if (columnUP != null && columnUP.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Column user property with this name is already exists in column {column.Name}."; } else { businessEntity.Column = column; businessEntity.ColumnId = column.Id; } } return(businessEntity); }
public override BUSPickMap Init(TContext context) { BUSPickMap businessEntity = base.Init(context); Field field = context.Fields .AsNoTracking() .Select(f => new { id = f.Id, busComp = f.BusComp, pl = new { id = f.PickListId, busComp = f.PickList.BusComp } }) .Select(f => new Field { Id = f.id, BusComp = f.busComp, BusCompId = f.busComp.Id, PickList = new PickList { Id = (Guid)f.pl.id, BusComp = f.pl.busComp, BusCompId = f.pl.busComp.Id } }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Field")); if (field != null) { businessEntity.BusComp = field.BusComp; businessEntity.BusCompId = field.BusCompId; if (field.PickList?.BusComp != null) { businessEntity.PickListBusComp = field.PickList.BusComp; businessEntity.PickListBusCompId = field.PickList.BusCompId; } } return(businessEntity); }
public override void ExecuteQuery([FromBody] UIBusinessComponent 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.TableName)) { List <Guid?> tablesId = new List <Guid?>(); context.Tables.Where(n => n.Name.ToLower().Contains(model.TableName.ToLower())).ToList().ForEach(table => tablesId.Add(table.Id)); searchSpecArgs.Add(tablesId); searchSpecification = string.IsNullOrWhiteSpace(searchSpecification) ? "@0.Contains(TableId)" : $"{searchSpecification} && @1.Contains(TableId)"; } BusinessObjectComponent objectComponent = viewInfo.BOComponents.FirstOrDefault(n => n.Name == "Business Component"); ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecification, searchSpecification); ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecArgs, searchSpecArgs.ToArray()); }
public override BUSColumn Init(TContext context) { BUSColumn businessEntity = base.Init(context); Applet applet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, busCompId = a.BusCompId }) .Select(a => new Applet { Id = a.id, BusCompId = a.busCompId }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Applet")); if (applet != null) { businessEntity.BusComp = applet.BusComp; businessEntity.BusCompId = applet.BusCompId; } return(businessEntity); }
public override BUSTableColumn UIToBusiness(UITableColumn UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSTableColumn businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); Table table = context.Tables .AsNoTracking() .Select(t => new { id = t.Id, name = t.Name, tableColumns = t.TableColumns.Select(tableColumn => new { id = tableColumn.Id, name = tableColumn.Name, }) }) .Select(t => new Table { Id = t.id, Name = t.name, TableColumns = t.tableColumns.Select(tableColumn => new TableColumn { Id = tableColumn.id, Name = tableColumn.name }).ToList() }) .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Table")); if (table == null) { businessEntity.ErrorMessage = "First you need create table."; } else { // Если запись новая и она не уникальна, записывается ошибка TableColumn tableColumn = table.TableColumns?.FirstOrDefault(n => n.Name == UIEntity.Name); if (table.TableColumns != null && tableColumn != null && tableColumn.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Table column with this name is already exists in table {table.Name}."; } else { // Table businessEntity.Table = table; businessEntity.TableId = table.Id; // Foreign Key if (UIEntity.IsForeignKey) { // Внешняя таблица Table foreignTable = context.Tables .AsNoTracking() .Select(t => new { id = t.Id, name = t.Name, tableColumns = t.TableColumns.Select(tableColumn => new { id = tableColumn.Id, name = tableColumn.Name, }) }) .Select(t => new Table { Id = t.id, Name = t.name, TableColumns = t.tableColumns.Select(tableColumn => new TableColumn { Id = tableColumn.id, Name = tableColumn.name }).ToList() }) .FirstOrDefault(n => n.Name == UIEntity.ForeignTableName); if (foreignTable != null) { businessEntity.ForeignTable = foreignTable; businessEntity.ForeignTableId = foreignTable.Id; businessEntity.ForeignTableName = foreignTable.Name; // Внешний ключ для таблицы TableColumn foreignTableColumn = foreignTable.TableColumns.FirstOrDefault(n => n.Name == UIEntity.ForeignTableKeyName); if (foreignTableColumn != null) { businessEntity.ForeignTableKey = foreignTableColumn; businessEntity.ForeignTableKeyId = foreignTableColumn.Id; businessEntity.ForeignTableKeyName = foreignTableColumn.Name; businessEntity.ExtencionType = UIEntity.ExtencionType; businessEntity.OnDelete = UIEntity.OnDelete; businessEntity.OnUpdate = UIEntity.OnUpdate; } } } businessEntity.Type = UIEntity.Type; businessEntity.IsForeignKey = UIEntity.IsForeignKey; businessEntity.IsNullable = UIEntity.IsNullable; businessEntity.Length = Convert.ToInt32(UIEntity.Length); } } return(businessEntity); }
public virtual ActionResult <string> UpdateContext() { // Список проверенных бк, список с верхними в иерархии бк и список с апплетами для обновления List <Applet> appletsToUpdate = new List <Applet>(); List <BusinessObjectComponent> topComponents = new List <BusinessObjectComponent>(); viewInfo.AppletsSortedByLinks.Clear(); // Необходимо выбрать те компоненты, у которых нет связей, либо те, которые являются верхними в иерархии viewInfo.BOComponents.ForEach(component => { // Если у компоненты нет линки, то она добавляется в список верхних в иерархии if (component.Link == null) { topComponents.Add(component); } // Иначе находится ее родительская компонента из связи else { BusinessObjectComponent parentComponent = viewInfo.BOComponents.FirstOrDefault(i => i.BusCompId == component.Link.ParentBCId); // Если родительской бк нет в представлении, текущая компонента добавляется в список верхних в иерархии if (parentComponent == null) { topComponents.Add(component); } // Иначе до тех пор пока по связям можно подниматься наверх в списке бк текущего представления else { while (viewInfo.BOComponents.IndexOf(parentComponent) != -1) { // Если у родительской компоненты нет ссылки она добавляется в список верхних в иерархии if (parentComponent.Link == null) { if (topComponents.IndexOf(parentComponent) == -1) { topComponents.Add(parentComponent); } break; } // Иначе компонента становится равной родительской компоненте из линки parentComponent = viewInfo.BOComponents.FirstOrDefault(i => i.BusCompId == parentComponent.Link.ParentBCId); } } } }); /* Для каждой компоненты, верхней в иерархии, запускается формирование списка апплетов, необходимых для обновления * И для всех компонент, отсутствующих в представлении, но являющихся верхними в иерархии для списка topComponents необходимо установить контекст */ topComponents.ForEach(component => { List <BusinessObjectComponent> boComponents = viewInfo.ViewBO.BusObjectComponents; List <BusinessObjectComponent> parentComponents = new List <BusinessObjectComponent>(); if (component.Link != null) { BusinessObjectComponent parentComponent = boComponents.FirstOrDefault(i => i.BusCompId == component.Link.ParentBCId); parentComponents.Add(parentComponent); while (parentComponent?.Link != null) { parentComponent = boComponents.FirstOrDefault(i => i.BusCompId == parentComponent.Link.ParentBCId); parentComponents.Add(parentComponent); } parentComponents.AsEnumerable().Reverse().ToList().ForEach(item => { BusinessComponent busComp = context.BusinessComponents .Include(f => f.Fields) .FirstOrDefault(i => i.Id == item.BusCompId); TBUSFactory busFactory = new TBUSFactory(); if (!ComponentsRecordsInfo.IsInitComponent(busComp.Name)) { busFactory.InitializeComponentsRecords(null, context, viewInfo, new FilterEntitiesModel() { BOComponents = boComponents, Link = item.Link, BusComp = busComp }); } }); } // Добавление всех апплетов не являющихся попапами в список для обновления viewInfo.ViewApplets.ForEach(viewApplet => { if (viewApplet.Type != "Popup") { appletsToUpdate.Add(viewApplet); } }); viewInfo.AppletsSortedByLinks.AddRange(AppletListBuilding(new List <BusinessObjectComponent>(), component, component, appletsToUpdate)); }); return(Ok()); }
public ActionResult Drilldown() { Applet currentApplet = viewInfo.CurrentPopupApplet ?? viewInfo.CurrentApplet; currentApplet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, type = a.Type, busComp = new { id = a.BusComp.Id, name = a.BusComp.Name, routing = a.BusComp.Routing }, drilldowns = a.Drilldowns.Select(d => new { id = d.Id, name = d.Name, hyperLinkFieldId = d.HyperLinkFieldId, sourceField = new { id = d.SourceField.Id, name = d.SourceField.Name }, destinationBusinessComponent = new { id = d.DestinationBusinessComponent.Id, name = d.DestinationBusinessComponent.Name, routing = d.DestinationBusinessComponent.Routing }, destinationField = new { id = d.DestinationField.Id, name = d.DestinationField.Name }, destinationScreenId = d.DestinationScreenId, destinationScreenItemId = d.DestinationScreenItemId, destinationScreenItem = new { id = d.DestinationScreenItem.Id, view = new { id = d.DestinationScreenItem.View.Id, busObjectId = d.DestinationScreenItem.View.BusObjectId } } }) }) .Select(a => new Applet { Id = a.id, Name = a.name, Type = a.type, BusComp = new BusinessComponent { Id = a.busComp.id, Name = a.busComp.name, Routing = a.busComp.routing }, Drilldowns = a.drilldowns.Select(d => new Drilldown { Id = d.id, Name = d.name, HyperLinkFieldId = d.hyperLinkFieldId, SourceField = new Field { Id = d.sourceField.id, Name = d.sourceField.name }, DestinationBusinessComponent = new BusinessComponent { Id = d.destinationBusinessComponent.id, Name = d.destinationBusinessComponent.name, Routing = d.destinationBusinessComponent.routing }, DestinationField = new Field { Id = d.destinationField.id, Name = d.destinationField.name }, DestinationScreenId = d.destinationScreenId, DestinationScreenItem = new ScreenItem { Id = d.destinationScreenItem.id, View = new View { Id = d.destinationScreenItem.view.id, BusObjectId = d.destinationScreenItem.view.busObjectId } } }).ToList() }) .FirstOrDefault(i => i.Id == currentApplet.Id); if (currentApplet != null) { string controlName; Field field; switch (currentApplet.Type) { case "Tile": controlName = viewInfo.CurrentColumn.Name; field = viewInfo.CurrentColumn.Field; break; default: controlName = viewInfo.CurrentPopupControl?.Name ?? viewInfo.CurrentControl?.Name; field = viewInfo.CurrentPopupControl?.Field ?? viewInfo.CurrentControl?.Field; break; } if (field != null) { TBUSFactory BUSFactory = new TBUSFactory(); Drilldown drilldown = currentApplet.Drilldowns.FirstOrDefault(i => i.HyperLinkFieldId == field.Id); if (drilldown != null && drilldown.DestinationBusinessComponent?.Name != null && drilldown.DestinationField?.Name != null && drilldown.SourceField?.Name != null) { // Целевой экран Screen destinationScreen = context.Screens.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenId); if (destinationScreen != null) { applicationInfo.CurrentScreen = destinationScreen; // Целевыое представление View destinationView = context.Views.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenItem.View.Id); if (destinationView != null) { applicationInfo.CurrentView = destinationView; // Исходное поле dynamic sourceRecord = BUSFactory.GetRecord(null, context, viewInfo, currentApplet.BusComp, "Id", viewInfo.CurrentRecord); PropertyInfo sourceProperty = sourceRecord.GetType().GetProperty(drilldown.SourceField.Name); if (sourceProperty != null) { // Очистка старой информации о выбранных записях if (screenInfo.Screen.Name != destinationScreen.Name) { ComponentsRecordsInfo.Dispose(); } // Установка текущей выбранной записи на целевой бизнес компоненте var sourcePropertyValue = sourceProperty.GetValue(sourceRecord); if (sourcePropertyValue != null) { dynamic destinationRecord = BUSFactory.GetRecord(null, context, viewInfo, drilldown.DestinationBusinessComponent, drilldown.DestinationField.Name, sourcePropertyValue.ToString()); if (destinationRecord != null) { ComponentsRecordsInfo.SetSelectedRecord(drilldown.DestinationBusinessComponent.Name, destinationRecord.Id.ToString()); } // Установка текущих выбранных записей на всех родительских бизнес компонентах целевой компоненты BusinessObject destinationBO = context.BusinessObjects .AsNoTracking() .Include(boc => boc.BusObjectComponents) .ThenInclude(l => l.Link) .ThenInclude(cf => cf.ChildField) .Include(boc => boc.BusObjectComponents) .ThenInclude(l => l.Link) .ThenInclude(pf => pf.ParentField) .FirstOrDefault(i => i.Id == destinationView.BusObjectId); BusinessObjectComponent destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == drilldown.DestinationBusinessComponent.Id); dynamic childRecord = destinationRecord; if (destinationComponent.Link != null) { BusinessComponent parentBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, table = new { id = bc.Table.Id, name = bc.Table.Name } }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Table = new Table { Id = bc.table.id, Name = bc.table.name } }) .FirstOrDefault(i => i.Id == destinationComponent.Link.ParentBCId); BusinessComponent childBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name }) .FirstOrDefault(i => i.Id == destinationComponent.Link.ChildBCId); string childFieldValue = childRecord.GetType().GetProperty(destinationComponent.Link.ChildField.Name).GetValue(childRecord).ToString(); string parentFieldName = destinationComponent.Link.ParentField.Name; IEnumerable <dynamic> parentRecords = (IEnumerable <dynamic>)(context.GetType().GetProperty(parentBusComp.Table.Name).GetValue(context)); string searchSpecificationByParent = $"{parentFieldName} = \"{childFieldValue}\""; dynamic parentRecord = parentRecords.AsQueryable().Where(searchSpecificationByParent).FirstOrDefault(); ComponentsRecordsInfo.SetSearchSpecification(childBusComp.Name, SearchSpecTypes.SearchSpecificationByParent, searchSpecificationByParent); ComponentsRecordsInfo.SetSelectedRecord(parentBusComp.Name, parentRecord.Id.ToString()); destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == destinationComponent.Link.ParentBCId); childRecord = parentRecord; } // Установка хлебных крошек ScreenItem crumb = screenInfo.Screen.ScreenItems.FirstOrDefault(n => n.View != null && n.View.Name == screenInfo.CurrentView.Name); ComponentsRecordsInfo.AppendCrumb(crumb); if (screenInfo.Screen.Name == destinationScreen.Name) { screenInfo.Initialize(screenInfo.Screen.Name, destinationView.Name, context); screenInfoUI.Initialize(screenInfo, context); viewInfo.View = destinationView; } viewInfo.ActionType = ActionType.Drilldown; } } } } } } } return(Ok()); }
public static List <TTable> FilterEntities(TContext context, FilterEntitiesModel model, IEnumerable <TTable> dataEntities) { if (model.Link != null) { TDataBUSFactory dataBUSFactory = new TDataBUSFactory(); BusinessObjectComponent objectComponent = model.BOComponents.FirstOrDefault(bcId => bcId.BusCompId == model.BusComp.Id); // Родительская БК и филды BusinessComponent parentBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, table = bc.Table, fields = bc.Fields.Select(field => new { id = field.Id, name = field.Name }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Table = bc.table, Fields = bc.fields.Select(field => new Field { Id = field.id, Name = field.name }).ToList() }) .FirstOrDefault(i => i.Id == model.Link.ParentBCId); Field parentField = parentBusComp.Fields.FirstOrDefault(i => i.Id == model.Link.ParentFieldId); Field childField = model.BusComp.Fields.FirstOrDefault(i => i.Id == model.Link.ChildFieldId); // Родительская запись var recordId = ComponentsRecordsInfo.GetSelectedRecord(parentBusComp.Name); IEnumerable <dynamic> parentRecords = (IEnumerable <dynamic>)(context.GetType().GetProperty(parentBusComp.Table.Name).GetValue(context)); dynamic parentRecord = parentRecords.FirstOrDefault(i => i.Id.ToString() == recordId); // Значение родитеского поля из родительской БКО по которому будет фильтроваться дочерняя(текущая БКО) string parentFieldValue = parentRecord == null ? string.Empty : parentRecord.GetType().GetProperty(parentField.Name).GetValue(parentRecord).ToString(); /* Установка search spec-а по дочерней(текущей) БКО * Если на родительской бк есть записи, надо фильтровать дочернюю бк */ if (parentFieldValue != string.Empty) { string searchSpecificationByParent = $"{childField.Name} = \"{parentFieldValue}\""; ComponentsRecordsInfo.SetSearchSpecification(objectComponent.Name, SearchSpecTypes.SearchSpecificationByParent, searchSpecificationByParent); dataEntities = dataEntities.AsQueryable().Where(searchSpecificationByParent).ToList(); } // Если записей нет, значит надо очистить дочернюю бк else { dataEntities = new List <TTable>(); } return(dataEntities.Take(10).ToList()); } else { var selectedRecordId = ComponentsRecordsInfo.GetSelectedRecord(model.BusComp.Name); if (selectedRecordId != null) { return(dataEntities.SkipWhile(i => i.Id.ToString() != selectedRecordId).Take(10).ToList()); } else { return(dataEntities.Take(10).ToList()); } } }
public void Initialize <TContext>(string screenName, string currentView, TContext context) where TContext : MainContext, new() { AggregateViews = new List <ScreenItem>(); AggregateCategories = new List <ScreenItem>(); AllCategoriesViews = new Dictionary <ScreenItem, List <ScreenItem> >(); CurrentCategoryViews = new List <ScreenItem>(); ChildViews = new List <ScreenItem>(); Crumbs = new List <ScreenItem>(); Screen = context.Screens .AsNoTracking() .Include(si => si.ScreenItems) .ThenInclude(v => v.View) .Include(si => si.ScreenItems) .ThenInclude(p => p.ParentCategory) .FirstOrDefault(n => n.Name == screenName); List <ScreenItem> ScreenItems = Screen.ScreenItems.ToList(); AggregateViews = ScreenItems.Where(t => t.Type == ScreenItemTypes.AggregateView.ToString()).OrderBy(s => s.Sequence).ToList(); AggregateCategories = ScreenItems.Where(t => t.Type == ScreenItemTypes.AggregateCategory.ToString()).OrderBy(s => s.Sequence).ToList(); AggregateCategories.ForEach(category => { AllCategoriesViews.Add(category, Screen.ScreenItems.Where(c => c.ParentCategoryId == category.Id).ToList()); }); // При первой загрузке скрина, когда отсутсвует текущее представление if (currentView == null) { // В таком случае текущим представлением становится первое представление в текущей категории, у которого нет родителей CurrentView = AggregateViews.Where(p => p.ParentItemId == null).OrderBy(s => s.Sequence).FirstOrDefault(); } // Иначе текущее представление - то, что пришло с фронта else { CurrentView = AggregateViews.FirstOrDefault(n => n.View.Name == currentView); } if (CurrentView?.ParentCategory != null) { /* Если не было подано название текущей категории, значит происходит первая загрузка скрина * и надо взять первую категорию. */ CurrentCategory = AggregateCategories.FirstOrDefault(i => i.Id == CurrentView.ParentCategoryId); // Все представления текущей категории CurrentCategoryViews = ScreenItems.Where(p => p.ParentCategoryId == CurrentCategory.Id).ToList(); // Дочерние представления ChildViews = CurrentCategoryViews .Where(p => p.ParentItemId == CurrentView.Id) .OrderBy(s => s.Sequence).ToList(); // Родительское представление ParentView = CurrentCategoryViews.FirstOrDefault(n => n.Id == CurrentView.ParentItemId); } // Хлебные крошки Crumbs = ComponentsRecordsInfo.GetCrumbs().ToList(); }
public override BUSJoin UIToBusiness(UIJoin UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSJoin businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); BusinessComponent busComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, joins = bc.Joins.Select(join => new { id = join.Id, name = join.Name }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Joins = bc.joins.Select(join => new Join { Id = join.id, Name = join.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Component")); if (busComp == null) { businessEntity.ErrorMessage = "First you need create business component."; } else { // Если запись новая и она не уникальна, записывается ошибка Join join = busComp.Joins?.FirstOrDefault(n => n.Name == UIEntity.Name); if (join != null && join.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Join with this name is already exists in business component {busComp.Name}."; } else { // BusComp businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; // Table Table table = context.Tables.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.TableName); if (table != null) { businessEntity.Table = table; businessEntity.TableId = table.Id; businessEntity.TableName = table.Name; } } } return(businessEntity); }
public override BUSDataMapObject UIToBusiness(UIDataMapObject UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSDataMapObject businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); DataMap dataMap = context.DataMaps .Select(map => new { id = map.Id, name = map.Name, dataMapObjects = map.DataMapObjects.Select(mapObject => new { id = mapObject.Id, name = mapObject.Name }) }) .Select(map => new DataMap { Id = map.id, Name = map.name, DataMapObjects = map.dataMapObjects.Select(mapObject => new DataMapObject { Id = mapObject.id, Name = mapObject.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Data Map")); if (dataMap == null) { businessEntity.ErrorMessage = "First you need create data map."; } else { // Если запись новая и она не уникальна, записывается ошибка DataMapObject dataMapObject = dataMap.DataMapObjects?.FirstOrDefault(n => n.Name == UIEntity.Name); if (dataMapObject != null && dataMapObject.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Data map object with this name is already exists in data map {businessEntity.DataMap.Name}."; } else { businessEntity.DataMap = dataMap; businessEntity.DataMapId = dataMap.Id; // SourceBusinessObject BusinessObject sourceBusinessObject = context.BusinessObjects.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.SourceBusinessObjectName); if (sourceBusinessObject != null) { businessEntity.SourceBusinessObject = sourceBusinessObject; businessEntity.SourceBusinessObjectId = sourceBusinessObject.Id; businessEntity.SourceBusinessObjectName = sourceBusinessObject.Name; } // DestinationBusinessObject BusinessObject destinationBusinessObject = context.BusinessObjects.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.DestinationBusinessObjectName); if (destinationBusinessObject != null) { businessEntity.DestinationBusinessObject = destinationBusinessObject; businessEntity.DestinationBusinessObjectId = destinationBusinessObject.Id; businessEntity.DestinationBusinessObjectName = destinationBusinessObject.Name; } } } return(businessEntity); }
public override IEnumerable <ValidationResult> UIValidate(TContext context, IViewInfo viewInfo, UIDirectoriesList UIEntity, bool isNewRecord) { List <ValidationResult> result = base.UIValidate(context, viewInfo, UIEntity, isNewRecord).ToList(); DirectoriesList directoryList = context.DirectoriesList.AsNoTracking().FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Directories List")); DirectoriesList directoriesList = context.DirectoriesList.AsNoTracking() .FirstOrDefault(n => n.DirectoryType == UIEntity.DirectoryType && n.LIC == UIEntity.LIC && n.Language == UIEntity.Language); if (directoriesList != null && directoriesList.Id != UIEntity.Id) { result.Add(new ValidationResult( $"Directory list with this language independent code and language is already exists in directory type {UIEntity.DirectoryType}.", new List <string>() { "DirectoryType" })); } if (string.IsNullOrWhiteSpace(UIEntity.DirectoryType)) { result.Add(new ValidationResult( "Display type is a required field.", new List <string>() { "DirectoryType" })); } if (string.IsNullOrWhiteSpace(UIEntity.DisplayValue)) { result.Add(new ValidationResult( "Display value is a required field.", new List <string>() { "DisplayValue" })); } if (string.IsNullOrWhiteSpace(UIEntity.LIC)) { result.Add(new ValidationResult( "Language independent code is a required field.", new List <string>() { "LIC" })); } if (string.IsNullOrWhiteSpace(UIEntity.Language)) { result.Add(new ValidationResult( "Language is a required field.", new List <string>() { "DisplayValue" })); } return(result); }
public override BUSApplicationItem UIToBusiness(UIApplicationItem UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSApplicationItem businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); Application application = context.Applications .AsNoTracking() .Select(app => new { id = app.Id, name = app.Name, items = app.ApplicationItems.Select(item => new { id = item.Id, name = item.Name }) }) .Select(app => new Application { Id = app.id, Name = app.name, ApplicationItems = app.items.Select(item => new ApplicationItem { Id = item.id, Name = item.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Application")); if (application == null) { businessEntity.ErrorMessage = "First you need create application."; } else { // Если запись новая и она не уникальна, записывается ошибка ApplicationItem applicationItem = application?.ApplicationItems.FirstOrDefault(n => n.Name == UIEntity.Name); if (applicationItem != null && applicationItem.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Application item with this name is already exists in application {application.Name}"; } else { businessEntity.Application = application; businessEntity.ApplicationId = application.Id; // Экран Screen screen = context.Screens.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.ScreenName); if (screen != null) { businessEntity.Screen = screen; businessEntity.ScreenId = screen.Id; businessEntity.ScreenName = screen.Name; } } } return(businessEntity); }
public override BUSBusinessObjectComponent UIToBusiness(UIBusinessObjectComponent UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSBusinessObjectComponent businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); BusinessObject busObject = context.BusinessObjects .AsNoTracking() .Select(bo => new { id = bo.Id, name = bo.Name, components = bo.BusObjectComponents.Select(boc => new { id = boc.Id, name = boc.Name }) }) .Select(bo => new BusinessObject { Id = bo.id, Name = bo.name, BusObjectComponents = bo.components.Select(boc => new BusinessObjectComponent { Id = boc.id, Name = boc.name }).ToList() }) .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Object")); if (busObject == null) { businessEntity.ErrorMessage = "First you need create business object."; } else { // Если запись новая и она не уникальна, записывается ошибка BusinessObjectComponent businessObjectComponent = busObject.BusObjectComponents?.FirstOrDefault(n => n.Name == UIEntity.Name); if (businessObjectComponent != null && businessObjectComponent.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Business object component with this name is already exists in business object {busObject.Name}."; } else { // BusObject businessEntity.BusObject = busObject; businessEntity.BusObjectId = busObject.Id; businessEntity.BusObjectName = busObject.Name; // 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; } // Link Link link = context.Links.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.LinkName); if (link != null) { businessEntity.Link = link; businessEntity.LinkId = link.Id; businessEntity.LinkName = link.Name; } } } return(businessEntity); }
public override BUSDataMapObjectComponent Init(TContext context) { BUSDataMapObjectComponent businessEntity = base.Init(context); DataMapObject dataMapObject = context.DataMapObjects .AsNoTracking() .Select(mapObject => new { id = mapObject.Id, sourceBusinessObjectId = mapObject.SourceBusinessObjectId, destinationBusinessObjectId = mapObject.DestinationBusinessObjectId }) .Select(mapObject => new DataMapObject { Id = mapObject.id, SourceBusinessObjectId = mapObject.sourceBusinessObjectId, DestinationBusinessObjectId = mapObject.destinationBusinessObjectId }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Data Map Object")); if (dataMapObject != null) { businessEntity.DataMapObject = dataMapObject; businessEntity.DataMapObjectId = dataMapObject.Id; businessEntity.SourceBusinessObjectId = dataMapObject.SourceBusinessObjectId; businessEntity.DestinationBusinessObjectId = dataMapObject.DestinationBusinessObjectId; } return(businessEntity); }
public override BUSDataMapObjectComponent UIToBusiness(UIDataMapObjectComponent UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSDataMapObjectComponent businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); DataMapObject dataMapObject = context.DataMapObjects .AsNoTracking() .Select(mapObject => new { id = mapObject.Id, name = mapObject.Name, sourceBusinessObjectId = mapObject.SourceBusinessObjectId, destinationBusinessObjectId = mapObject.DestinationBusinessObjectId, dataMapComponents = mapObject.DataMapObjectComponents.Select(mapComponent => new { id = mapComponent.Id, name = mapComponent.Name }) }) .Select(mapObject => new DataMapObject { Id = mapObject.id, Name = mapObject.name, SourceBusinessObjectId = mapObject.sourceBusinessObjectId, DestinationBusinessObjectId = mapObject.destinationBusinessObjectId, DataMapObjectComponents = mapObject.dataMapComponents.Select(mapComponent => new DataMapObjectComponent { Id = mapComponent.id, Name = mapComponent.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Data Map Object")); if (dataMapObject == null) { businessEntity.ErrorMessage = "First you need create data map object."; } else { DataMapObjectComponent mapObjectComponent = dataMapObject?.DataMapObjectComponents.FirstOrDefault(n => n.Name == UIEntity.Name); if (dataMapObject?.SourceBusinessObjectId == Guid.Empty) { businessEntity.ErrorMessage = $"At first you need to add a source business object to data map object {dataMapObject.Name}."; } if (dataMapObject?.DestinationBusinessObjectId == Guid.Empty) { businessEntity.ErrorMessage = $"At first you need to add a destination business object to data map object {dataMapObject.Name}."; } else if (mapObjectComponent != null && mapObjectComponent.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Data map component with this name is already exists in data map object {dataMapObject.Name}."; } else { businessEntity.DataMapObject = dataMapObject; businessEntity.DataMapObjectId = dataMapObject.Id; // SourceBusinessObject BusinessObject sourceBusinessObject = context.BusinessObjects .AsNoTracking() .Select(bo => new { id = bo.Id, busObjectComponents = bo.BusObjectComponents.Select(boc => new { id = boc.Id, name = boc.Name, busComp = new { id = boc.BusComp.Id, name = boc.BusComp.Name } }) }) .Select(bo => new BusinessObject { Id = bo.id, BusObjectComponents = bo.busObjectComponents.Select(boc => new BusinessObjectComponent { Id = boc.id, Name = boc.name, BusComp = new BusinessComponent { Id = boc.busComp.id, Name = boc.busComp.name } }).ToList() }) .FirstOrDefault(i => i.Id == dataMapObject.SourceBusinessObjectId); if (sourceBusinessObject != null) { businessEntity.SourceBusinessObject = sourceBusinessObject; businessEntity.SourceBusinessObjectId = sourceBusinessObject.Id; // SourceBusinessComponent BusinessObjectComponent sourceBOComponent = sourceBusinessObject.BusObjectComponents.FirstOrDefault(n => n.BusComp.Name == UIEntity.SourceBOComponentName); if (sourceBOComponent != null) { businessEntity.SourceBOComponent = sourceBOComponent; businessEntity.SourceBOComponentId = sourceBOComponent.Id; businessEntity.SourceBOComponentName = sourceBOComponent.Name; BusinessComponent sourceBusinessComponent = context.BusinessComponents.FirstOrDefault(i => i.Id == sourceBOComponent.BusComp.Id); businessEntity.SourceBusinessComponent = sourceBusinessComponent; businessEntity.SourceBusinessComponentId = sourceBusinessComponent.Id; } } // DestinationBusinessObject BusinessObject destinationBusinessObject = context.BusinessObjects .AsNoTracking() .Select(bo => new { id = bo.Id, busObjectComponents = bo.BusObjectComponents.Select(boc => new { id = boc.Id, name = boc.Name, busComp = new { id = boc.BusComp.Id, name = boc.BusComp.Name } }) }) .Select(bo => new BusinessObject { Id = bo.id, BusObjectComponents = bo.busObjectComponents.Select(boc => new BusinessObjectComponent { Id = boc.id, Name = boc.name, BusComp = new BusinessComponent { Id = boc.busComp.id, Name = boc.busComp.name } }).ToList() }) .FirstOrDefault(i => i.Id == dataMapObject.DestinationBusinessObjectId); if (destinationBusinessObject != null) { businessEntity.DestinationBusinessObject = destinationBusinessObject; businessEntity.DestinationBusinessObjectId = destinationBusinessObject.Id; // DestinationBusinessComponent BusinessObjectComponent destinationBOComponent = destinationBusinessObject.BusObjectComponents.FirstOrDefault(n => n.BusComp.Name == UIEntity.DestinationBOComponentName); if (destinationBOComponent != null) { businessEntity.DestinationBOComponent = destinationBOComponent; businessEntity.DestinationBOComponentId = destinationBOComponent.Id; businessEntity.DestinationBOComponentName = destinationBOComponent.Name; BusinessComponent destinationBusinessComponent = context.BusinessComponents.FirstOrDefault(i => i.Id == destinationBOComponent.BusComp.Id); businessEntity.DestinationBusinessComponent = destinationBusinessComponent; businessEntity.DestinationBusinessComponentId = destinationBusinessComponent.Id; } } // ParentDataMapComponent DataMapObjectComponent parentDataMapComponent = dataMapObject.DataMapObjectComponents.FirstOrDefault(n => n.Name == UIEntity.ParentDataMapComponentName); if (parentDataMapComponent != null) { businessEntity.ParentDataMapComponent = parentDataMapComponent; businessEntity.ParentDataMapComponentId = parentDataMapComponent.Id; businessEntity.ParentDataMapComponentName = parentDataMapComponent.Name; } businessEntity.SourceSearchSpecification = UIEntity.SourceSearchSpecification; } } return(businessEntity); }