public void Persist(ClassDiagram classDiagram, CreateClassDiagramCommand command) { foreach (var contentItem in command.Contents) { var classDiagramContent = new ClassDiagramContent(); classDiagramContent.Id = Guid.NewGuid(); classDiagramContent.Locale = contentItem.Locale; classDiagramContent.Name = contentItem.Name; classDiagram.Contents.Add(classDiagramContent); _classDiagramContentRepository.Add(classDiagramContent); } foreach (var classData in command.Classes) { PersistClass(classDiagram, classData); } foreach (var relationData in command.Relations) { var classRelation = new ClassRelationship(); classRelation.Id = Guid.NewGuid(); classRelation.SourceId = relationData.SourceId.Value; classRelation.SourceMultiplicity = relationData.SourceMultiplicity; classRelation.TargetId = relationData.TargetId.Value; classRelation.TargetMultiplicity = relationData.TargetMultiplicity; classRelation.Type = relationData.Type.Value; classDiagram.Relationships.Add(classRelation); _classRelationRepository.Add(classRelation); } }
public static ClassDiagramContentViewModel FromModel(ClassDiagramContent model) { return(new ClassDiagramContentViewModel { Locale = model.Locale, Name = model.Name }); }