public override BUSLink Init(TContext context) { BUSLink businessEntity = base.Init(context); businessEntity.ParentBCId = Guid.Empty; businessEntity.ChildBCId = Guid.Empty; return(businessEntity); }
public override Link BusinessToData(Link link, BUSLink businessEntity, TContext context, bool NewRecord) { Link dataEntity = base.BusinessToData(link, businessEntity, context, NewRecord); dataEntity.ParentBCId = businessEntity.ParentBCId; dataEntity.ParentFieldId = businessEntity.ParentFieldId; dataEntity.ChildBCId = businessEntity.ChildBCId; dataEntity.ChildFieldId = businessEntity.ChildFieldId; return(dataEntity); }
public override UILink BusinessToUI(BUSLink businessEntity) { UILink UIEntity = base.BusinessToUI(businessEntity); UIEntity.ChildBCName = businessEntity.ChildBCName; UIEntity.ChildFieldName = businessEntity.ChildFieldName; UIEntity.ParentBCName = businessEntity.ParentBCName; UIEntity.ParentFieldName = businessEntity.ParentFieldName; return(UIEntity); }
public override BUSLink DataToBusiness(Link dataEntity, TContext context) { BUSLink businessEntity = base.DataToBusiness(dataEntity, context); // Parent bc BusinessComponent parentBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, fields = bc.Fields.Select(field => new { id = field.Id, name = field.Name, }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Fields = bc.fields.Select(field => new Field { Id = field.id, Name = field.name }).ToList() }) .FirstOrDefault(i => i.Id == dataEntity.ParentBCId); if (parentBusComp != null) { businessEntity.ParentBusComp = parentBusComp; businessEntity.ParentBCId = parentBusComp.Id; businessEntity.ParentBCName = parentBusComp.Name; // Parent field Field parentField = parentBusComp.Fields.FirstOrDefault(i => i.Id == dataEntity.ParentFieldId); if (parentField != null) { businessEntity.ParentField = parentField; businessEntity.ParentFieldId = parentField.Id; businessEntity.ParentFieldName = parentField.Name; } } // Child bc BusinessComponent childBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, fields = bc.Fields.Select(field => new { id = field.Id, name = field.Name, }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Fields = bc.fields.Select(field => new Field { Id = field.id, Name = field.name }).ToList() }) .FirstOrDefault(i => i.Id == dataEntity.ChildBCId); if (childBusComp != null) { businessEntity.ChildBusComp = childBusComp; businessEntity.ChildBCId = childBusComp.Id; businessEntity.ChildBCName = childBusComp.Name; // Child field Field childField = childBusComp.Fields.FirstOrDefault(i => i.Id == dataEntity.ChildFieldId); if (childField != null) { businessEntity.ChildField = childField; businessEntity.ChildFieldId = childField.Id; businessEntity.ChildFieldName = childField.Name; } } return(businessEntity); }
public override IEnumerable <ValidationResult> BUSUIValidate(TContext context, BUSLink businessComponent, UILink UIEntity) { List <ValidationResult> result = base.BUSUIValidate(context, businessComponent, UIEntity).ToList(); if (string.IsNullOrWhiteSpace(businessComponent.ErrorMessage)) { if (businessComponent.ParentBCName == null) { result.Add(new ValidationResult( "Business component with this name not found.", new List <string>() { "ParentBCName" })); } else if (businessComponent.ParentFieldName == null) { result.Add(new ValidationResult( "Field with this name not found.", new List <string>() { "ParentFieldName" })); } if (businessComponent.ChildBCName == null) { result.Add(new ValidationResult( "Business component with this name not found.", new List <string>() { "ChildBCName" })); } else if (businessComponent.ChildFieldName == null) { result.Add(new ValidationResult( "Field with this name not found.", new List <string>() { "ChildFieldName" })); } } return(result); }
public override BUSLink UIToBusiness(UILink UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSLink businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); // Parent bc BusinessComponent parentBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, fields = bc.Fields.Select(field => new { id = field.Id, name = field.Name, }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Fields = bc.fields.Select(field => new Field { Id = field.id, Name = field.name }).ToList() }) .FirstOrDefault(n => n.Name == UIEntity.ParentBCName); if (parentBusComp != null) { businessEntity.ParentBusComp = parentBusComp; businessEntity.ParentBCId = parentBusComp.Id; businessEntity.ParentBCName = parentBusComp.Name; } // Parent field Field parentField = parentBusComp.Fields.FirstOrDefault(n => n.Name == UIEntity.ParentFieldName); if (parentField != null) { businessEntity.ParentField = parentField; businessEntity.ParentFieldId = parentField.Id; businessEntity.ParentFieldName = parentField.Name; } // Child bc BusinessComponent childBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, fields = bc.Fields.Select(field => new { id = field.Id, name = field.Name, }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Fields = bc.fields.Select(field => new Field { Id = field.id, Name = field.name }).ToList() }) .FirstOrDefault(n => n.Name == UIEntity.ChildBCName); if (childBusComp != null) { businessEntity.ChildBusComp = childBusComp; businessEntity.ChildBCId = childBusComp.Id; businessEntity.ChildBCName = childBusComp.Name; } // Child field Field childField = childBusComp.Fields.FirstOrDefault(n => n.Name == UIEntity.ChildFieldName); if (childField != null) { businessEntity.ChildField = childField; businessEntity.ChildFieldId = childField.Id; businessEntity.ChildFieldName = childField.Name; } return(businessEntity); }