private static CasePlanAggregate BuildCasePlan(tCase tCase, tDefinitions definitions, CaseFileAggregate caseFile) { var planModel = tCase.casePlanModel; var roles = new List <CasePlanRole>(); var files = new List <CasePlanFileItem>(); if (tCase.caseRoles != null && tCase.caseRoles.role != null) { foreach (var role in tCase.caseRoles.role) { roles.Add(new CasePlanRole { Id = role.id, Name = role.name }); } } if (tCase.caseFileModel != null && tCase.caseFileModel.caseFileItem != null) { foreach (var caseFileItem in tCase.caseFileModel.caseFileItem) { var caseFileItemDef = definitions.caseFileItemDefinition.First(c => c.id == caseFileItem.definitionRef.ToString()); files.Add(new CasePlanFileItem { DefinitionType = caseFileItemDef.definitionType, Id = caseFileItem.id, Name = caseFileItem.name }); } } return(CasePlanAggregate.New(planModel.id, planModel.name, planModel.name, caseFile.AggregateId, caseFile.Version, Serialize(planModel), roles, files)); }
public Task Update(CasePlanAggregate workflowDefinition, CancellationToken token) { var wf = _caseDefinitions.First(w => w.AggregateId == workflowDefinition.AggregateId); _caseDefinitions.Remove(wf); _caseDefinitions.Add((CasePlanAggregate)wf.Clone()); return(Task.CompletedTask); }
public static CasePlanResult ToDto(CasePlanAggregate casePlan) { return(new CasePlanResult { CaseFile = casePlan.CaseFileId, CreateDateTime = casePlan.CreateDateTime, Description = casePlan.Description, NbInstances = casePlan.NbInstances, Id = casePlan.AggregateId, Name = casePlan.Name, Version = casePlan.Version, CasePlanId = casePlan.CasePlanId }); }
public async Task Delete(CasePlanAggregate workflowDefinition, CancellationToken token) { using (var lck = await _dbContext.Lock()) { var result = await _dbContext.CasePlans.FirstOrDefaultAsync(_ => _.Id == workflowDefinition.AggregateId, token); if (result == null) { return; } _dbContext.CasePlans.Remove(result); } }
public static CasePlanModel ToModel(this CasePlanAggregate casePlan) { return(new CasePlanModel { Id = casePlan.AggregateId, Version = casePlan.Version, CasePlanId = casePlan.CasePlanId, Name = casePlan.Name, NbInstances = casePlan.NbInstances, Description = casePlan.Description, CaseFileId = casePlan.CaseFileId, CreateDateTime = casePlan.CreateDateTime, Roles = casePlan.Roles.Select(_ => ToModel(_, casePlan.AggregateId)).ToList(), Files = casePlan.Files.Select(_ => ToModel(_, casePlan.AggregateId)).ToList(), SerializedContent = casePlan.XmlContent }); }
public Task Delete(CasePlanAggregate workflowDefinition, CancellationToken token) { _caseDefinitions.Remove(_caseDefinitions.First(c => c.AggregateId == workflowDefinition.AggregateId)); return(Task.CompletedTask); }
public Task Add(CasePlanAggregate workflowDefinition, CancellationToken token) { _caseDefinitions.Add((CasePlanAggregate)workflowDefinition.Clone()); return(Task.CompletedTask); }
public Task Add(CasePlanAggregate workflowDefinition, CancellationToken token) { _dbContext.CasePlans.Add(workflowDefinition.ToModel()); return(Task.CompletedTask); }
public Task Update(CasePlanAggregate casePlan, CancellationToken token) { _dbContext.CasePlans.Update(casePlan); return(Task.CompletedTask); }