public MultiOperationResponse ConstructFromMultiple([Required, FromBody] MultiOperationRequest request) { if (request.Setters.HasItems()) { var errors = ForeachMultiple(request.Lites, lite => { var entity = lite.RetrieveAndForget(); MultiSetter.SetSetters(entity, request.Setters, PropertyRoute.Root(entity.GetType())); var op = request.GetOperationSymbol(entity.GetType()); OperationLogic.ServiceConstructFrom(entity, op, request.ParseArgs(op)); }); return(new MultiOperationResponse(errors)); } else { var errors = ForeachMultiple(request.Lites, lite => { var op = request.GetOperationSymbol(lite.EntityType); OperationLogic.ServiceConstructFromLite(lite, op, request.ParseArgs(op)); }); return(new MultiOperationResponse(errors)); } }
public ActionResult ConstructFrom() { OperationSymbol operationSymbol; Entity entity = null; if (this.IsLite()) { Lite <Entity> lite = this.ExtractLite <Entity>(); entity = OperationLogic.ServiceConstructFromLite(lite, operationSymbol = this.GetOperationKeyAssert(lite.EntityType)); } else { MappingContext context = this.UntypedExtractEntity().UntypedApplyChanges(this).UntypedValidate(); entity = (Entity)context.UntypedValue; if (context.HasErrors()) { return(context.ToJsonModelState()); } try { entity = OperationLogic.ServiceConstructFrom(entity, operationSymbol = this.GetOperationKeyAssert(entity.GetType())); } catch (IntegrityCheckException e) { context.ImportErrors(e.Errors); return(context.ToJsonModelState()); } } return(this.DefaultConstructResult(entity, operation: operationSymbol)); }
public EntityPackTS?ConstructFromEntity([Required, FromBody] EntityOperationRequest request) { var op = request.GetOperationSymbol(request.entity.GetType()); var entity = OperationLogic.ServiceConstructFrom(request.entity, op, request.ParseArgs(op)); return(entity == null ? null : SignumServer.GetEntityPack(entity)); }
public void Execute(ExecutingProcess executingProcess) { PackageOperationEntity package = (PackageOperationEntity)executingProcess.Data; OperationSymbol operationSymbol = package.Operation; var args = package.OperationArgs; executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line => { OperationType operationType = OperationLogic.OperationType(line.Target.GetType(), operationSymbol); switch (operationType) { case OperationType.Execute: OperationLogic.ServiceExecute(line.Target, operationSymbol, args); break; case OperationType.Delete: OperationLogic.ServiceDelete(line.Target, operationSymbol, args); break; case OperationType.ConstructorFrom: { var result = OperationLogic.ServiceConstructFrom(line.Target, operationSymbol, args); line.Result = result.ToLite(); } break; default: throw new InvalidOperationException("Unexpected operation type {0}".FormatWith(operationType)); } line.FinishTime = TimeZoneManager.Now; line.Save(); }); }
public EntityPackTS ConstructFromEntity(EntityOperationRequest request) { var entity = OperationLogic.ServiceConstructFrom(request.entity, request.GetOperationSymbol(request.entity.GetType()), request.args); return(entity == null ? null: SignumServer.GetEntityPack(entity)); }
public Entity ConstructFrom(IEntity entity, OperationSymbol operationSymbol, params object[] args) { return(Return(MethodInfo.GetCurrentMethod(), operationSymbol.ToString(), () => OperationLogic.ServiceConstructFrom(entity, operationSymbol, args))); }
public EntityPackTS ConstructFromEntity(EntityOperationRequest request) { var entity = OperationLogic.ServiceConstructFrom(request.entity, request.operarionSymbol, request.args); return(SignumServer.GetEntityPack(entity)); }