public static UseCaseDiagramContentViewModel FromModel(UseCaseDiagramContent model) { return(new UseCaseDiagramContentViewModel { Locale = model.Locale, Name = model.Name }); }
public void Persist(UseCaseDiagram useCaseDiagram, CreateUseCaseDiagramCommand command, IEnumerable <UseCase> oldVersionUseCases = null) { foreach (var contentItem in command.Contents) { var useCaseDiagramContent = new UseCaseDiagramContent(); useCaseDiagramContent.Id = Guid.NewGuid(); useCaseDiagramContent.Locale = contentItem.Locale; useCaseDiagramContent.Name = contentItem.Name; useCaseDiagram.Contents.Add(useCaseDiagramContent); _useCaseDiagramContentRepository.Add(useCaseDiagramContent); } var projectId = _currentProjectContextId.Get(); var useCaseId = _useCaseNextIdQueryHandler.Handle(projectId); foreach (var useCaseData in command.UseCases) { var currentUseCaseId = useCaseData.Identifier == null ? useCaseId++ : useCaseData.Identifier.Value; PersistUseCase(useCaseDiagram, useCaseData, currentUseCaseId, oldVersionUseCases); } foreach (var actorData in command.Actors) { PersistActor(useCaseDiagram, actorData); } foreach (var relationData in command.EntitiesRelations) { var entitiesRelation = new UseCaseEntityRelation(); entitiesRelation.Id = Guid.NewGuid(); var source = useCaseDiagram.Entities .FirstOrDefault(e => e.Id == relationData.SourceId.Value); var target = useCaseDiagram.Entities .FirstOrDefault(e => e.Id == relationData.TargetId.Value); entitiesRelation.Source = source; entitiesRelation.Target = target; if (relationData.Contents != null) { foreach (var content in relationData.Contents) { var relationContent = new UseCaseEntityRelationContent(); relationContent.Description = content.Description; relationContent.Locale = content.Locale; relationContent.Id = entitiesRelation.Id; _useCaseEntityRelationContentRepository.Add(relationContent); } } useCaseDiagram.EntitiesRelations.Add(entitiesRelation); _useCaseEntityRelationRepository.Add(entitiesRelation); } foreach (var relationData in command.UseCasesRelations) { var useCasesRelation = new UseCasesRelation(); useCasesRelation.Version = useCaseDiagram.Version; useCasesRelation.SourceId = relationData.SourceId.Value; useCasesRelation.TargetId = relationData.TargetId.Value; useCasesRelation.Type = relationData.Type.Value; useCasesRelation.UseCaseDiagram = useCaseDiagram; useCaseDiagram.UseCasesRelations.Add(useCasesRelation); _useCasesRelationRepository.Add(useCasesRelation); useCasesRelation.Id = Guid.NewGuid(); } }