/// <summary> /// Creates a new sub entity and assigns the parent entity specified in the query strings. /// Note: Either the parent ID or parent unique key need to be provided, not both. /// </summary> /// <param name="parentID">The ID of the parent entity.</param> /// <param name="uniqueKey">The unique key of the parent entity.</param> /// <returns>The newly created sub entity.</returns> public IEntity Create(Guid parentID, string parentUniqueKey) { IEntity entity = null; using (LogGroup logGroup = LogGroup.Start("Creating a new sub entity.", NLog.LogLevel.Debug)) { CreateSubEntityStrategy createStrategy = (CreateSubEntityStrategy)CreateStrategy.New(Command.TypeName, Container.RequireAuthorisation); entity = createStrategy.Create(parentID, parentUniqueKey); ExecuteCreate(entity); } return(entity); }
public void Test_Create_FromParentID() { TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>(); article.ID = Guid.NewGuid(); article.Title = "Test Title"; SaveStrategy.New <TestArticle>(false).Save(article); CreateSubEntityStrategy strategy = (CreateSubEntityStrategy)CreateStrategy.New("TestArticlePage", false); TestArticlePage page = strategy.Create <TestArticlePage>(article.ID, String.Empty); Assert.IsNotNull(page.Article, "The article wasn't assigned to the page."); Assert.AreEqual(article.Title, page.Article.Title, "Article titles don't match."); Assert.AreEqual(1, page.PageNumber, "Invalid page number"); }