public HttpResponseMessage <bool> UpdateWorkflow(long id, [FromBody] EC.EntityNugget entityNugget) { using (Profiler.Measure("WorkflowController.UpdateWorkflow")) { HttpResponseMessage <bool> result = null; DatabaseContext.RunWithRetry(() => { Action updateAction = () => { MDL.IEntity updatedEntity = EC.EntityNugget.DecodeEntity(entityNugget, true); var wf = updatedEntity.As <MDL.Workflow>(); if (updatedEntity == null) { throw new WebArgumentException("Workflow update does not contain data"); } if (updatedEntity.Id != id) { throw new WebArgumentException("Request and nugget ids do not match"); } updatedEntity.Save(); }; bool isCloned = WorkflowUpdateHelper.Update(id, updateAction); result = new HttpResponseMessage <bool>(isCloned); }); return(result); } }
private SecurityTestData SetupSecurityTest(IEnumerable <Tuple <string, string> > nameAndDescription) { var testData = new SecurityTestData(); // Create entity type var entityType = EntityModel.Entity.Create <EntityModel.EntityType>(); entityType.Name = "TestType"; entityType.Inherits.Add(EntityModel.Entity.Get <EntityModel.EntityType>("core:userResource")); entityType.Save(); testData.EntityType = entityType; // Create entity instances foreach (var nameDesc in nameAndDescription) { EntityModel.IEntity entity = EntityModel.Entity.Create(entityType); entity.SetField("core:name", nameDesc.Item1); entity.SetField("core:description", nameDesc.Item2); entity.Save(); testData.EntityInstances.Add(entity); } // Create query Guid resourceGuid = Guid.NewGuid(); var structuredQuery = new StructuredQuery { RootEntity = new ResourceEntity { EntityTypeId = entityType.Id, ExactType = false, NodeId = resourceGuid }, SelectColumns = new List <SelectColumn>() }; structuredQuery.SelectColumns.Add(new SelectColumn { Expression = new IdExpression { NodeId = resourceGuid } }); structuredQuery.SelectColumns.Add(new SelectColumn { Expression = new ResourceDataColumn { NodeId = resourceGuid, FieldId = EntityModel.Entity.GetId("core:name") } }); structuredQuery.SelectColumns.Add(new SelectColumn { Expression = new ResourceDataColumn { NodeId = resourceGuid, FieldId = EntityModel.Entity.GetId("core:description") } }); // Create report var report = ReportToEntityModelHelper.ConvertToEntity(structuredQuery); report.Save(); testData.Report = report; // Create user var userAccount = new EntityModel.UserAccount(); userAccount.Save(); testData.UserAccount = userAccount; return(testData); }