Skip to content

Commit

Permalink
#611 content cloning bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JimKerslake committed Nov 19, 2024
1 parent a8e2a47 commit 94904a0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using cloudscribe.SimpleContent.Storage.EFCore.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -131,21 +132,33 @@ public async Task<string> CloneToNewProject(

if (page == null) throw new InvalidOperationException("page not found");

var p = PageEntity.FromIPage(page);
p.Id = Guid.NewGuid().ToString();
var p = PageEntity.FromIPage(page);
p.Id = Guid.NewGuid().ToString();
p.LastModified = DateTime.UtcNow;
p.ProjectId = targetProjectId;
p.ProjectId = targetProjectId;
dbContext.Pages.Add(p);

int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);

if (page.Resources.Count > 0)
if (page.PageResources.Count > 0)
{
p.Resources = page.Resources;
p.PageResources = new List<PageResourceEntity>();

// why did Joe need both page.Resources and page.PageResources? - jk
foreach (var r in page.PageResources)
{
r.PageEntityId = p.Id;
var newRes = new PageResourceEntity
{
PageEntityId = p.Id,
ContentId = p.Id,
Environment = r.Environment,
Sort = r.Sort,
Type = r.Type,
Url = r.Url
};
p.PageResources.Add(newRes);
}

rowsAffected = await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>base package - Entity Framework Core implementation of cloudscribe SimpleContent commands and queries</Description>
<Version>8.0.2</Version>
<Version>8.0.3</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;commands;queries;ef</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>MSSQL Entity Framework Core implementation of cloudscribe SimpleContent commands and queries</Description>
<Version>8.0.3</Version>
<Version>8.0.4</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;commands;queries;ef</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>MySQL Entity Framework Core implementation of cloudscribe SimpleContent commands and queries</Description>
<Version>8.0.3</Version>
<Version>8.0.4</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;commands;queries;ef</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>PostgreSql Entity Framework Core implementation of cloudscribe SimpleContent commands and queries</Description>
<Version>8.0.2</Version>
<Version>8.0.3</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;commands;queries;ef</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>SQLite Entity Framework Core implementation of cloudscribe SimpleContent commands and queries</Description>
<Version>8.0.2</Version>
<Version>8.0.3</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;commands;queries;ef</PackageTags>
Expand Down

0 comments on commit 94904a0

Please sign in to comment.