refactor(model): rename Yavsc.Blogspot.BlogPost to BlogPostDto
When commit 0e95e283 moved BlogPost from PostIt.Models to
Yavsc.Blogspot, it created an unfortunate collision with the
server-side EF entity Yavsc.Models.Blog.BlogPost. The two
classes have nothing in common beyond the name; the DTO is
the wire shape PostIt exchanges with the Blogs API, the EF
entity is the persistence model. Server code that imports both
namespaces (BlogSpotService.cs, etc.) ended up with 'BlogPost
is an ambiguous reference between X and Y' errors.
Renaming the client DTO to BlogPostDto (matching the
naming convention of the other DTOs in Yavsc.Api.Client.Dtos
— CircleDto, CircleAuthorizationDto, UserSearchResultDto)
disambiguates without renaming the EF entity on the server.
The namespace stays Yavsc.Blogspot; only the class name
changes. All call sites (client code, tests, XAML DataTemplates,
XML doc comments) are updated mechanically.
This commit is contained in:
parent
0e7576857d
commit
1b289c1387
12 changed files with 43 additions and 43 deletions
|
|
@ -25,7 +25,7 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
/// previous "{Binding SelectedPost.Title}" binding, the user's
|
||||
/// keystrokes were silently dropped whenever
|
||||
/// <c>SelectedPost was null</c>, which made the editor a trap
|
||||
/// and caused Save to POST a <c>BlogPost</c> with an empty
|
||||
/// and caused Save to POST a <c>BlogPostDto</c> with an empty
|
||||
/// title — hence the 400 "The Title field is required".</summary>
|
||||
[ObservableProperty]
|
||||
public partial string DraftTitle { get; set; }
|
||||
|
|
@ -47,13 +47,13 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
public partial string SearchText { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial ObservableCollection<BlogPost> Posts { get; set; }
|
||||
public partial ObservableCollection<BlogPostDto> Posts { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial ObservableCollection<BlogPost> FilteredPosts { get; set; }
|
||||
public partial ObservableCollection<BlogPostDto> FilteredPosts { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial BlogPost? SelectedPost { get; set; }
|
||||
public partial BlogPostDto? SelectedPost { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsBusy { get; set; }
|
||||
|
|
@ -83,8 +83,8 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
private void Init(Settings? settings)
|
||||
{
|
||||
SearchText = string.Empty;
|
||||
Posts = new ObservableCollection<BlogPost>();
|
||||
FilteredPosts = new ObservableCollection<BlogPost>();
|
||||
Posts = new ObservableCollection<BlogPostDto>();
|
||||
FilteredPosts = new ObservableCollection<BlogPostDto>();
|
||||
SelectedPost = null;
|
||||
IsBusy = false;
|
||||
StatusMessage = "Ready";
|
||||
|
|
@ -120,7 +120,7 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
|
||||
partial void OnSearchTextChanged(string value) => ApplyFilter();
|
||||
|
||||
partial void OnSelectedPostChanged(BlogPost? value)
|
||||
partial void OnSelectedPostChanged(BlogPostDto? value)
|
||||
{
|
||||
// Mirror the selection into the editor buffer so the
|
||||
// XAML-bound TextBox/TextEditor show the right content
|
||||
|
|
@ -177,7 +177,7 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
|
||||
await ExecuteAsync(async () =>
|
||||
{
|
||||
// Build a fresh BlogPost from the editor buffer on
|
||||
// Build a fresh BlogPostDto from the editor buffer on
|
||||
// every Save — we no longer mutate SelectedPost in
|
||||
// place. The previous behaviour copied the buffer
|
||||
// (which was a no-op when SelectedPost was null)
|
||||
|
|
@ -189,7 +189,7 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
// the update path.
|
||||
if (SelectedPost is null || SelectedPost.Id == 0)
|
||||
{
|
||||
var draft = new BlogPost
|
||||
var draft = new BlogPostDto
|
||||
{
|
||||
Title = DraftTitle,
|
||||
Article = DraftArticle ?? string.Empty,
|
||||
|
|
@ -205,7 +205,7 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
}
|
||||
else
|
||||
{
|
||||
var update = new BlogPost
|
||||
var update = new BlogPostDto
|
||||
{
|
||||
Id = SelectedPost.Id,
|
||||
AuthorId = SelectedPost.AuthorId,
|
||||
|
|
@ -327,7 +327,7 @@ public partial class MainPageViewModel : ViewModelBase
|
|||
/// because the navigation surface (<c>NavigationPage</c>) lives
|
||||
/// in the View layer.
|
||||
/// </summary>
|
||||
public event EventHandler<BlogPost>? ManageAclRequested;
|
||||
public event EventHandler<BlogPostDto>? ManageAclRequested;
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanManageAcl))]
|
||||
public void ManageAcl()
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public partial class PostAclDialogViewModel : ViewModelBase
|
|||
|
||||
/// <summary>The post whose ACL is being edited. Set by the
|
||||
/// caller (MainPage) when opening the dialog.</summary>
|
||||
public BlogPost Post { get; }
|
||||
public BlogPostDto Post { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial ObservableCollection<CircleDto> MyCircles { get; set; } = new();
|
||||
|
|
@ -52,7 +52,7 @@ public partial class PostAclDialogViewModel : ViewModelBase
|
|||
public partial string StatusMessage { get; set; } = string.Empty;
|
||||
|
||||
public PostAclDialogViewModel(
|
||||
BlogPost post,
|
||||
BlogPostDto post,
|
||||
BlogAclApiClient aclClient,
|
||||
CircleApiClient circleClient)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
<ListBox ItemsSource="{Binding FilteredPosts}" SelectedItem="{Binding SelectedPost, Mode=TwoWay}"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:BlogPost">
|
||||
<DataTemplate x:DataType="models:BlogPostDto">
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" />
|
||||
<TextBlock Text="{Binding DateModified, StringFormat='Updated: {0:yyyy-MM-dd HH:mm}'}" FontSize="10" Foreground="Gray" />
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public partial class MainPage : ContentPage
|
|||
}
|
||||
}
|
||||
|
||||
void OnManageAclRequested(object? sender, BlogPost post)
|
||||
void OnManageAclRequested(object? sender, BlogPostDto post)
|
||||
{
|
||||
var app = Application.Current as App;
|
||||
var services = app?.ServiceProvider;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public partial class PostAclDialog : ContentPage
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PostAclDialog(BlogPost post, BlogAclApiClient aclClient, CircleApiClient circleClient)
|
||||
public PostAclDialog(BlogPostDto post, BlogAclApiClient aclClient, CircleApiClient circleClient)
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new PostAclDialogViewModel(post, aclClient, circleClient);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue