Skip to content

Commit

Permalink
Ensure solution builds
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Nov 14, 2023
1 parent 9c17dfe commit dc69b40
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Collections.ObjectModel;
using MZikmund.Api.Client;
using MZikmund.DataContracts.Blog.Categories;
using MZikmund.DataContracts.Blog;
using MZikmund.Extensions;
using MZikmund.Models.Dialogs;
using MZikmund.Services.Dialogs;
using MZikmund.Services.Loading;
using MZikmund.Services.Localization;
using MZikmund.ViewModels;
using Newtonsoft.Json;
using Windows.Storage.Pickers;

Expand All @@ -30,7 +29,7 @@ public BlogCategoriesManagerViewModel(

public override string Title => Localizer.Instance.GetString("BlogCategories");

public ObservableCollection<BlogCategoryDto> Categories { get; } = new ObservableCollection<BlogCategoryDto>();
public ObservableCollection<Category> Categories { get; } = new ObservableCollection<Category>();

public override async void ViewAppeared()
{
Expand Down Expand Up @@ -61,7 +60,7 @@ private async Task ImportJsonAsync()
picker.FileTypeFilter.Add(".json");
var jsonFile = await picker.PickSingleFileAsync();
var jsonContent = await FileIO.ReadTextAsync(jsonFile);
var Categories = JsonConvert.DeserializeObject<BlogCategoryDto[]>(jsonContent);
var Categories = JsonConvert.DeserializeObject<Category[]>(jsonContent);
if (Categories == null)
{
return;
Expand All @@ -71,8 +70,8 @@ private async Task ImportJsonAsync()
{
var tag = Categories[i];
_loadingIndicator.StatusMessage = $"Adding tag {i + 1} of {Categories.Length}";
// Ensure tag ID is 0.
tag.Id = 0;
// Ensure tag ID is empty.
tag.Id = Guid.Empty;

await _api.AddBlogCategoryAsync(tag);
}
Expand Down
13 changes: 6 additions & 7 deletions src/app/MZikmund/ViewModels/Admin/BlogTagsManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
using MZikmund.Models.Dialogs;
using MZikmund.Services.Dialogs;
using MZikmund.Services.Loading;
using MZikmund.ViewModels;
using Newtonsoft.Json;
using Windows.Storage.Pickers;
using MZikmund.Services.Localization;
using MZikmund.DataContracts.Blog.Tags;
using MZikmund.DataContracts.Blog;

namespace MZikmund.ViewModels.Admin;

Expand All @@ -30,7 +29,7 @@ public BlogTagsManagerViewModel(

public override string Title => Localizer.Instance.GetString("BlogTags");

public ObservableCollection<BlogTagDto> Tags { get; } = new ObservableCollection<BlogTagDto>();
public ObservableCollection<Tag> Tags { get; } = new ObservableCollection<Tag>();

public override async void ViewAppeared()
{
Expand Down Expand Up @@ -61,7 +60,7 @@ private async Task ImportJsonAsync()
picker.FileTypeFilter.Add(".json");
var jsonFile = await picker.PickSingleFileAsync();
var jsonContent = await FileIO.ReadTextAsync(jsonFile);
var tags = JsonConvert.DeserializeObject<BlogTagDto[]>(jsonContent);
var tags = JsonConvert.DeserializeObject<Tag[]>(jsonContent);
if (tags == null)
{
return;
Expand All @@ -71,8 +70,8 @@ private async Task ImportJsonAsync()
{
var tag = tags[i];
_loadingIndicator.StatusMessage = $"Adding tag {i + 1} of {tags.Length}";
// Ensure tag ID is 0.
tag.Id = 0;
// Ensure tag ID is empty.
tag.Id = Guid.Empty;

await _api.AddBlogTagAsync(tag);
}
Expand Down Expand Up @@ -101,7 +100,7 @@ private async Task AddBlogTagAsync()
//});
}

public async Task UpdateBlogTagAsync(BlogTagDto dto)
public async Task UpdateBlogTagAsync(Tag dto)
{
var viewModel = new AddOrUpdateBlogTagDialogViewModel();
var result = await _dialogService.ShowAsync(viewModel);
Expand Down
4 changes: 2 additions & 2 deletions src/app/MZikmund/Views/Admin/BlogCategoriesManagerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xaml="using:MZikmund.Extensions.Xaml"
xmlns:dto="using:MZikmund.DataContracts.Blog.Categories"
xmlns:dto="using:MZikmund.DataContracts.Blog"
mc:Ignorable="d"
d:Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

Expand Down Expand Up @@ -38,7 +38,7 @@
</TransitionCollection>
</GridView.ItemContainerTransitions>
<GridView.ItemTemplate>
<DataTemplate x:DataType="dto:BlogCategoryDto">
<DataTemplate x:DataType="dto:Category">
<StackPanel Background="{ThemeResource SystemColorHighlightBrush}" Width="120" Padding="8">
<TextBlock FontWeight="Bold" Text="{x:Bind DisplayName}" TextTrimming="CharacterEllipsis" />
<TextBlock Opacity="0.8" Text="{x:Bind RouteName}" TextTrimming="CharacterEllipsis" />
Expand Down
4 changes: 2 additions & 2 deletions src/app/MZikmund/Views/Admin/BlogTagsManagerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MZikmund.Views.Admin"
xmlns:dto="using:MZikmund.DataContracts.Blog.Tags"
xmlns:dto="using:MZikmund.DataContracts.Blog"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xaml="using:MZikmund.Extensions.Xaml"
Expand Down Expand Up @@ -38,7 +38,7 @@
</TransitionCollection>
</GridView.ItemContainerTransitions>
<GridView.ItemTemplate>
<DataTemplate x:DataType="dto:BlogTagDto">
<DataTemplate x:DataType="dto:Tag">
<StackPanel Background="{ThemeResource SystemColorHighlightBrush}" Width="120" Padding="8">
<TextBlock FontWeight="Bold" Text="{x:Bind DisplayName}" TextTrimming="CharacterEllipsis" />
<TextBlock Opacity="0.8" Text="{x:Bind RouteName}" TextTrimming="CharacterEllipsis" />
Expand Down
18 changes: 9 additions & 9 deletions src/shared/MZikmund.Api/IMZikmundApi.BlogCategories.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using MZikmund.DataContracts.Blog.Categories;
using MZikmund.DataContracts.Blog;
using Refit;

namespace MZikmund.Api.Client;

public partial interface IMZikmundApi
{
[Get("/v1/blog/categories")]
Task<ApiResponse<BlogCategoryDto[]>> GetBlogCategoriesAsync();
[Get("/v1/categories")]
Task<ApiResponse<Category[]>> GetBlogCategoriesAsync();

[Post("/v1/blog/categories")]
[Post("/v1/admin/categories")]
[Headers("Authorization: Bearer")]
Task<ApiResponse<BlogCategoryDto>> AddBlogCategoryAsync(BlogCategoryDto category);
Task<ApiResponse<Category>> AddBlogCategoryAsync(Category category); // TODO: Should be EditCategory

[Put("/v1/blog/categories/{categoryId}")]
[Put("/v1/admin/categories/{categoryId}")]
[Headers("Authorization: Bearer")]
Task<ApiResponse<BlogCategoryDto>> UpdateCategoryAsync(int categoryId, BlogCategoryDto category);
Task<ApiResponse<Category>> UpdateCategoryAsync(Guid categoryId, EditCategory category);

[Delete("/v1/blog/categories/{categoryId}")]
[Delete("/v1/admin/categories/{categoryId}")]
[Headers("Authorization: Bearer")]
Task<ApiResponse<object?>> DeleteBlogCategoryAsync(int categoryId);
Task<ApiResponse<object?>> DeleteBlogCategoryAsync(Guid categoryId);
}
18 changes: 9 additions & 9 deletions src/shared/MZikmund.Api/IMZikmundApi.BlogTags.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using MZikmund.DataContracts.Blog.Tags;
using MZikmund.DataContracts.Blog;
using Refit;

namespace MZikmund.Api.Client;

public partial interface IMZikmundApi
{
[Get("/v1/blog/tags")]
Task<ApiResponse<BlogTagDto[]>> GetBlogTagsAsync();
[Get("/v1/tags")]
Task<ApiResponse<Tag[]>> GetBlogTagsAsync();

[Post("/v1/blog/tags")]
[Post("/v1/admin/tags")]
[Headers("Authorization: Bearer")]
Task<ApiResponse<BlogTagDto>> AddBlogTagAsync([Body] BlogTagDto category);
Task<ApiResponse<Tag>> AddBlogTagAsync([Body] Tag tag); // TODO: Should be EditTag

[Put("/v1/blog/tags/{categoryId}")]
[Put("/v1/admin/tags/{categoryId}")]
[Headers("Authorization: Bearer")]
Task<ApiResponse<BlogTagDto>> UpdateTagAsync(int categoryId, [Body] BlogTagDto category);
Task<ApiResponse<Tag>> UpdateTagAsync(int categoryId, [Body] EditTag tag);

[Delete("/v1/blog/tags/{categoryId}")]
[Delete("/v1/admin/tags/{categoryId}")]
[Headers("Authorization: Bearer")]
Task<ApiResponse<object?>> DeleteBlogTagAsync(int categoryId);
Task<ApiResponse<object?>> DeleteBlogTagAsync(int tagId);
}

0 comments on commit dc69b40

Please sign in to comment.