public override UIControl BusinessToUI(BUSControl businessEntity) { UIControl UIEntity = base.BusinessToUI(businessEntity); UIEntity.CssClass = businessEntity.CssClass; UIEntity.IconName = businessEntity.IconName; UIEntity.FieldName = businessEntity.FieldName; UIEntity.ActionType = businessEntity.ActionType.ToString(); UIEntity.Header = businessEntity.Header; UIEntity.Type = businessEntity.Type; UIEntity.Required = businessEntity.Required; UIEntity.Readonly = businessEntity.Readonly; return(UIEntity); }
public override Control BusinessToData(Control control, BUSControl businessEntity, TContext context, bool NewRecord) { Control dataEntity = base.BusinessToData(control, businessEntity, context, NewRecord); dataEntity.IconId = businessEntity.IconId; dataEntity.CssClass = businessEntity.CssClass; dataEntity.Applet = businessEntity.Applet; dataEntity.AppletId = businessEntity.AppletId; dataEntity.FieldId = businessEntity.FieldId; dataEntity.ActionType = businessEntity.ActionType; dataEntity.Header = businessEntity.Header; dataEntity.Type = businessEntity.Type; dataEntity.Required = businessEntity.Required; dataEntity.Readonly = businessEntity.Readonly; return(dataEntity); }
public override BUSControl Init(TContext context) { BUSControl 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 CpPackageEventControl(BUSControl common) : base(common) { _objDAO = new CpPackageEventDataAccess(common.Connnection); }
public override BUSControl UIToBusiness(UIControl UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSControl businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); Applet applet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, busCompId = a.BusCompId, controls = a.Controls.Select(control => new { id = control.Id, name = control.Name }) }) .Select(a => new Applet { Id = a.id, Name = a.name, BusCompId = a.busCompId, Controls = a.controls.Select(control => new Control { Id = control.id, Name = control.name }).ToList() }) .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Applet")); if (applet == null) { businessEntity.ErrorMessage = "First you need create applet."; } else { // Если запись новая и она не уникальна, записывается ошибка Control control = applet.Controls?.FirstOrDefault(n => n.Name == UIEntity.Name); if (control != null && control.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Control with this name is already exists in applet \"{applet.Name}\"."; } else { businessEntity.Applet = applet; businessEntity.AppletId = applet.Id; // BusComp BusinessComponent busComp = 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 == applet.BusCompId); // BusComp if (busComp != null) { businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; // Field Field field = busComp.Fields.FirstOrDefault(n => n.Name == UIEntity.FieldName); if (field != null) { businessEntity.Field = field; businessEntity.FieldId = field.Id; businessEntity.FieldName = UIEntity.FieldName; } } // Icon Icon icon = context.Icons.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.IconName); if (icon != null) { businessEntity.Icon = icon; businessEntity.IconId = icon.Id; businessEntity.IconName = icon.Name; } if (string.IsNullOrWhiteSpace(UIEntity.ActionType)) { businessEntity.ActionType = ActionType.None; } businessEntity.ActionType = (ActionType)Enum.Parse(typeof(ActionType), UIEntity.ActionType); businessEntity.Readonly = UIEntity.Readonly; businessEntity.Header = UIEntity.Header; businessEntity.Type = UIEntity.Type; businessEntity.Required = UIEntity.Required; businessEntity.CssClass = UIEntity.CssClass; } } return(businessEntity); }
public override IEnumerable <ValidationResult> BUSUIValidate(TContext context, BUSControl businessComponent, UIControl UIEntity) { List <ValidationResult> result = base.BUSUIValidate(context, businessComponent, UIEntity).ToList(); if (string.IsNullOrWhiteSpace(businessComponent.ErrorMessage)) { if (businessComponent.BusComp == null && !string.IsNullOrWhiteSpace(UIEntity.FieldName)) { result.Add(new ValidationResult( $"At first you need to add a business component to applet {businessComponent.Applet.Name}.", new List <string>() { "BusComp" })); } else if (businessComponent.BusComp != null && businessComponent.Field == null && !string.IsNullOrWhiteSpace(UIEntity.FieldName)) { result.Add(new ValidationResult("Field with this name not found.", new List <string>() { "FieldName" })); } if (businessComponent.Icon == null && !string.IsNullOrWhiteSpace(UIEntity.IconName)) { result.Add(new ValidationResult("Icon with this name not found.", new List <string>() { "IconName" })); } } return(result); }
public override BUSControl DataToBusiness(Control dataEntity, TContext context) { BUSControl businessEntity = base.DataToBusiness(dataEntity, context); // Applet Applet applet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, busComp = a.BusComp, busCompId = a.BusCompId }) .Select(a => new Applet { Id = a.id, Name = a.name, BusComp = a.busComp, BusCompId = a.busCompId }) .FirstOrDefault(i => i.Id == dataEntity.AppletId); businessEntity.Applet = applet; businessEntity.AppletId = applet.Id; businessEntity.BusComp = applet.BusComp; businessEntity.BusCompId = applet.BusCompId; // Icon Icon icon = context.Icons.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.IconId); if (icon != null) { businessEntity.IconId = icon.Id; businessEntity.IconName = icon.Name; } // Field Field field = context.Fields.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.FieldId); if (field != null) { businessEntity.Field = field; businessEntity.FieldId = field.Id; businessEntity.FieldName = field.Name; } else { dataEntity.Field = null; dataEntity.FieldId = null; } // Ридонли на филде приоритетнее ридонли на контроле, поэтому вначале проверяется филда. Затем, если на ней нет ридонли, то свойство берется с контрола if (field != null && field.Readonly) { businessEntity.Readonly = true; } else { businessEntity.Readonly = dataEntity.Readonly; } businessEntity.ActionType = dataEntity.ActionType; businessEntity.Header = dataEntity.Header; businessEntity.Type = dataEntity.Type; businessEntity.Required = dataEntity.Required; businessEntity.CssClass = dataEntity.CssClass; return(businessEntity); }