From 0e95e28327da24a27e06bbdcc8f0c3827427b0b1 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 17 Aug 2026 23:45:45 +0100 Subject: [PATCH] refactor(model): move BlogPost DTO from PostIt.Models to Yavsc.Blogspot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BlogPost is shared between the server (Yavsc.Server/Models/Blog/ BlogPost.cs is the EF entity) and any client that talks to the blogs API. Keeping the client-side DTO in PostIt.Models made sense when there was only one consumer; now that the Yavsc.Api.Client project is about to host BlogApiClient alongside CircleApiClient and BlogAclApiClient, the DTO has to live in a layer both the client project and PostIt can reference without inverting the dependency. Yavsc.Abstract is the existing home for cross-tier interfaces and DTOs (IBlogPost, IBlogPostPayLoad, IApplicationUser). Yavsc.Blogspot is the sub-namespace already used by the matching interface, so the new concrete class follows. Why not move Circle and CircleAuthorizationToBlogPost at the same time? Both depend on the concrete ApplicationUser class (via the Owner and Target/Allowed navigation properties) which lives in Yavsc.Server. Moving them would mean either dragging ApplicationUser into the abstract layer (huge blast radius — auth, billing, chat, etc.) or weakening the navigation properties (breaks EF Core shaping). They're staying where they are; the new Yavsc.Api.Client will get DTO counterparts instead. Updated call sites: - 4 .cs files: replace 'using PostIt.Models;' with 'using Yavsc.Blogspot;' where the file was actually using BlogPost. Files that only used SignaturePadData keep their 'using PostIt.Models;' — that type stays put. - 1 .axaml file: xmlns:models="using:PostIt.Models" -> xmlns:models="using:Yavsc.Blogspot" (one DataTemplate for the post list in MainPage). Build + tests green (51/51). --- src/PostIt.Tests/BlogApiTestFakes.cs | 2 +- src/PostIt.Tests/MainPageSaveTests.cs | 2 +- src/PostIt.Tests/PostItViewModelTests.cs | 2 +- src/PostIt/PostIt/Services/BlogApiClient.cs | 2 +- src/PostIt/PostIt/ViewModels/MainPageViewModel.cs | 2 +- src/PostIt/PostIt/Views/MainPage.axaml | 2 +- .../Blogspot}/BlogPost.cs | 15 +++++++-------- 7 files changed, 13 insertions(+), 14 deletions(-) rename src/{PostIt/PostIt/Models => Yavsc.Abstract/Blogspot}/BlogPost.cs (65%) diff --git a/src/PostIt.Tests/BlogApiTestFakes.cs b/src/PostIt.Tests/BlogApiTestFakes.cs index 755ce105..3f8b98b0 100644 --- a/src/PostIt.Tests/BlogApiTestFakes.cs +++ b/src/PostIt.Tests/BlogApiTestFakes.cs @@ -1,4 +1,4 @@ -using PostIt.Models; +using Yavsc.Blogspot; using PostIt.Services; using PostIt.ViewModels; using Yavsc.Models; diff --git a/src/PostIt.Tests/MainPageSaveTests.cs b/src/PostIt.Tests/MainPageSaveTests.cs index c76115d7..cea3e83f 100644 --- a/src/PostIt.Tests/MainPageSaveTests.cs +++ b/src/PostIt.Tests/MainPageSaveTests.cs @@ -2,7 +2,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Headless.XUnit; using Avalonia.VisualTree; -using PostIt.Models; +using Yavsc.Blogspot; using PostIt.Services; using PostIt.ViewModels; using PostIt.Views; diff --git a/src/PostIt.Tests/PostItViewModelTests.cs b/src/PostIt.Tests/PostItViewModelTests.cs index 48569915..d8de8025 100644 --- a/src/PostIt.Tests/PostItViewModelTests.cs +++ b/src/PostIt.Tests/PostItViewModelTests.cs @@ -1,4 +1,4 @@ -using PostIt.Models; +using Yavsc.Blogspot; using PostIt.Services; using PostIt.ViewModels; diff --git a/src/PostIt/PostIt/Services/BlogApiClient.cs b/src/PostIt/PostIt/Services/BlogApiClient.cs index 5e927b97..f2061927 100644 --- a/src/PostIt/PostIt/Services/BlogApiClient.cs +++ b/src/PostIt/PostIt/Services/BlogApiClient.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using PostIt.Models; +using Yavsc.Blogspot; namespace PostIt.Services; diff --git a/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs b/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs index e7ea26a0..e8024d7d 100644 --- a/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; -using PostIt.Models; +using Yavsc.Blogspot; using PostIt.Services; namespace PostIt.ViewModels; diff --git a/src/PostIt/PostIt/Views/MainPage.axaml b/src/PostIt/PostIt/Views/MainPage.axaml index 5c42e27c..1ab8d905 100644 --- a/src/PostIt/PostIt/Views/MainPage.axaml +++ b/src/PostIt/PostIt/Views/MainPage.axaml @@ -3,7 +3,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="using:PostIt.ViewModels" - xmlns:models="using:PostIt.Models" + xmlns:models="using:Yavsc.Blogspot" xmlns:views="using:PostIt.Views" xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit" mc:Ignorable="d" diff --git a/src/PostIt/PostIt/Models/BlogPost.cs b/src/Yavsc.Abstract/Blogspot/BlogPost.cs similarity index 65% rename from src/PostIt/PostIt/Models/BlogPost.cs rename to src/Yavsc.Abstract/Blogspot/BlogPost.cs index e62fcea2..854aa29f 100644 --- a/src/PostIt/PostIt/Models/BlogPost.cs +++ b/src/Yavsc.Abstract/Blogspot/BlogPost.cs @@ -1,9 +1,8 @@ using System; using Yavsc.Abstract.Identity; using Yavsc.Abstract.Identity.Security; -using Yavsc.Blogspot; -namespace PostIt.Models; +namespace Yavsc.Blogspot; public class BlogPost : IBlogPost { @@ -13,12 +12,12 @@ public class BlogPost : IBlogPost public string Article { get; set ; } public string Photo { get; set ; } - public long Id { get; set ; } - public DateTime DateCreated { get; set ; } - public string UserCreated { get; set ; } - public DateTime DateModified { get; set ; } - public string UserModified { get; set ; } - public string Title { get; set ; } + public long Id { get; set; } + public DateTime DateCreated { get; set; } + public string UserCreated { get; set; } + public DateTime DateModified { get; set; } + public string UserModified { get; set; } + public string Title { get; set; } public bool AuthorizeCircle(long circleId) {