Skip to content

Commit 2d8fd52

Browse files
authored
Merge pull request #372 from KhanbalaRashidov/main
Code refactor
2 parents 75b6063 + 4e33ae8 commit 2d8fd52

File tree

7 files changed

+14
-41
lines changed

7 files changed

+14
-41
lines changed

src/Blogifier.Admin/Interop/CommonJsInterop.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
namespace Blogifier.Admin.Interop;
77

8-
public class CommonJsInterop : IAsyncDisposable
8+
public class CommonJsInterop(IJSRuntime jsRuntime) : IAsyncDisposable
99
{
10-
private readonly Lazy<Task<IJSObjectReference>> moduleTask;
11-
12-
public CommonJsInterop(IJSRuntime jsRuntime) =>
13-
moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>("import", "./admin/js/common.js").AsTask());
10+
private readonly Lazy<Task<IJSObjectReference>> moduleTask = new(() =>
11+
jsRuntime.InvokeAsync<IJSObjectReference>("import", "./admin/js/common.js").AsTask());
1412

1513
public async ValueTask SetTooltipAsync()
1614
{
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
namespace Blogifier.Shared;
22

3-
public class CategoryModel : PostPagerModel
3+
public class CategoryModel(string category, PostPagerDto pager, MainDto main) : PostPagerModel(pager, main)
44
{
5-
public string Category { get; set; }
6-
7-
public CategoryModel(string category, PostPagerDto pager, MainDto main) : base(pager, main)
8-
{
9-
Category = category;
10-
}
5+
public string Category { get; set; } = category;
116
}
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using Blogifier.Shared;
22
namespace Blogifier.Models;
33

4-
public class IndexModel : PostPagerModel
4+
public class IndexModel(PostPagerDto pager, MainDto main) : PostPagerModel(pager, main)
55
{
6-
public IndexModel(PostPagerDto pager, MainDto main) : base(pager, main)
7-
{
8-
}
96
}
+2-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
namespace Blogifier.Shared;
22

3-
public class MainModel
3+
public class MainModel(MainDto main)
44
{
5-
public MainDto Main { get; set; }
6-
7-
public MainModel(MainDto main)
8-
{
9-
Main = main;
10-
}
5+
public MainDto Main { get; set; } = main;
116
}
+3-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
namespace Blogifier.Shared;
22

3-
public class PostModel : MainModel
3+
public class PostModel(PostSlugDto postSlug, string categoriesUrl, MainDto main) : MainModel(main)
44
{
5-
public PostModel(PostSlugDto postSlug, string categoriesUrl, MainDto main) : base(main)
6-
{
7-
PostSlug = postSlug;
8-
CategoriesUrl = categoriesUrl;
9-
}
10-
public PostSlugDto PostSlug { get; set; }
11-
public string CategoriesUrl { get; set; }
5+
public PostSlugDto PostSlug { get; set; } = postSlug;
6+
public string CategoriesUrl { get; set; } = categoriesUrl;
127
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
namespace Blogifier.Shared;
22

3-
public class PostPagerModel : MainModel
3+
public class PostPagerModel(PostPagerDto pager, MainDto main) : MainModel(main)
44
{
5-
public PostPagerModel(PostPagerDto pager, MainDto main) : base(main)
6-
{
7-
Pager = pager;
8-
}
9-
public PostPagerDto Pager { get; }
5+
public PostPagerDto Pager { get; } = pager;
106
}
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
namespace Blogifier.Shared;
22

3-
public class SearchModel : PostPagerModel
3+
public class SearchModel(PostPagerDto pager, MainDto main) : PostPagerModel(pager, main)
44
{
5-
public SearchModel(PostPagerDto pager, MainDto main) : base(pager, main)
6-
{
7-
}
85
}

0 commit comments

Comments
 (0)