Skip to content

Commit 9b58e9f

Browse files
committed
Fixed stylecop violation in razor files
1 parent 6426063 commit 9b58e9f

13 files changed

+88
-88
lines changed

LinkDotNet.Blog.Web/Pages/Admin/CreateNewBlogPostPage.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
@using LinkDotNet.Blog.Web.Shared.Admin
55
@using LinkDotNet.Domain
66
@inherits MarkdownComponentBase
7-
@inject IRepository _repository
8-
@inject IToastService _toastService
7+
@inject IRepository repository
8+
@inject IToastService toastService
99

1010
<CreateNewBlogPost Title="Create new BlogPost" OnBlogPostCreated="@(StoreBlogPostAsync)" ></CreateNewBlogPost>
1111

1212
@code {
1313
private async Task StoreBlogPostAsync(BlogPost blogPost)
1414
{
15-
await _repository.StoreAsync(blogPost);
16-
_toastService.ShowInfo($"Created BlogPost {blogPost.Title}");
15+
await repository.StoreAsync(blogPost);
16+
toastService.ShowInfo($"Created BlogPost {blogPost.Title}");
1717
}
1818
}

LinkDotNet.Blog.Web/Pages/Admin/UpdateBlogPostPage.razor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
@using LinkDotNet.Blog.Web.Shared.Admin
55
@using LinkDotNet.Domain
66
@inherits MarkdownComponentBase
7-
@inject IRepository _repository
8-
@inject IToastService _toastService
7+
@inject IRepository repository
8+
@inject IToastService toastService
99

1010
@if (blogPostFromDb != null)
1111
{
@@ -33,13 +33,13 @@ else
3333
throw new ArgumentNullException(nameof(BlogPostId), "You have to provide an id");
3434
}
3535

36-
blogPostFromDb = await _repository.GetByIdAsync(BlogPostId);
36+
blogPostFromDb = await repository.GetByIdAsync(BlogPostId);
3737
}
3838

3939
private async Task StoreBlogPostAsync(BlogPost blogPost)
4040
{
4141
blogPostFromDb.Update(blogPost);
42-
await _repository.StoreAsync(blogPostFromDb);
43-
_toastService.ShowInfo($"Updated BlogPost {blogPost.Title}");
42+
await repository.StoreAsync(blogPostFromDb);
43+
toastService.ShowInfo($"Updated BlogPost {blogPost.Title}");
4444
}
4545
}

LinkDotNet.Blog.Web/Pages/BlogPostPage.razor

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
@using LinkDotNet.Infrastructure.Persistence
44
@using LinkDotNet.Blog.Web.Shared.Admin
55
@using Markdig
6-
@inject IRepository _repository
7-
@inject IJSRuntime _jsRuntime
6+
@inject IRepository repository
7+
@inject IJSRuntime jsRuntime
88
@inherits MarkdownComponentBase
99

1010
@if (BlogPost == null)
@@ -52,22 +52,22 @@ else
5252

5353
protected override async Task OnInitializedAsync()
5454
{
55-
BlogPost = await _repository.GetByIdAsync(BlogPostId);
55+
BlogPost = await repository.GetByIdAsync(BlogPostId);
5656
}
5757

5858
protected override async Task OnAfterRenderAsync(bool firstRender)
5959
{
6060
if (firstRender)
6161
{
62-
await _jsRuntime.InvokeVoidAsync("hljs.highlightAll");
62+
await jsRuntime.InvokeVoidAsync("hljs.highlightAll");
6363
StateHasChanged();
6464
}
6565
}
6666

6767
private async Task UpdateLikes(bool hasLiked)
6868
{
69-
BlogPost = await _repository.GetByIdAsync(BlogPostId);
69+
BlogPost = await repository.GetByIdAsync(BlogPostId);
7070
BlogPost.Likes = hasLiked ? BlogPost.Likes + 1 : BlogPost.Likes - 1;
71-
await _repository.StoreAsync(BlogPost);
71+
await repository.StoreAsync(BlogPost);
7272
}
7373
}

LinkDotNet.Blog.Web/Pages/Index.razor

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@
33
@using LinkDotNet.Infrastructure.Persistence
44
@using Markdig
55
@using X.PagedList
6-
@inject IRepository _repository
7-
@inject AppConfiguration _appConfiguration
8-
@inject NavigationManager _navigationManager
6+
@inject IRepository repository
7+
@inject AppConfiguration appConfiguration
8+
@inject NavigationManager navigationManager
99

10-
<OgData Title="@(Markdown.ToPlainText(_appConfiguration.BlogName))"
10+
<OgData Title="@(Markdown.ToPlainText(appConfiguration.BlogName))"
1111
AbsolutePreviewImageUrl="@GetAbsolutePreviewImageUrl()"
12-
Description="@(Markdown.ToPlainText(_appConfiguration.Introduction.Description))"></OgData>
12+
Description="@(Markdown.ToPlainText(appConfiguration.Introduction.Description))"></OgData>
1313
<section>
14-
<IntroductionCard Introduction="_appConfiguration.Introduction"></IntroductionCard>
14+
<IntroductionCard Introduction="appConfiguration.Introduction"></IntroductionCard>
1515

1616
<div class="content px-4">
17-
@for (var i = 0; i < _currentPage.Count; i++)
17+
@for (var i = 0; i < currentPage.Count; i++)
1818
{
19-
<ShortBlogPost BlogPost="_currentPage[i]" UseAlternativeStyle="@(i % 2 != 0)"></ShortBlogPost>
19+
<ShortBlogPost BlogPost="currentPage[i]" UseAlternativeStyle="@(i % 2 != 0)"></ShortBlogPost>
2020
}
2121
</div>
22-
<BlogPostNavigation CurrentPage="@_currentPage" OnPageChanged="@GetPage"></BlogPostNavigation>
22+
<BlogPostNavigation CurrentPage="@currentPage" OnPageChanged="@GetPage"></BlogPostNavigation>
2323
</section>
2424
@code {
25-
IPagedList<BlogPost> _currentPage = new PagedList<BlogPost>(Array.Empty<BlogPost>(), 1, 1);
25+
IPagedList<BlogPost> currentPage = new PagedList<BlogPost>(Array.Empty<BlogPost>(), 1, 1);
2626

2727
protected override async Task OnInitializedAsync()
2828
{
29-
_currentPage = await _repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: _appConfiguration.BlogPostsPerPage);
29+
currentPage = await repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: appConfiguration.BlogPostsPerPage);
3030
}
3131

3232
private string GetAbsolutePreviewImageUrl()
3333
{
34-
var backgroundUrl = _appConfiguration.Introduction.BackgroundUrl;
34+
var backgroundUrl = appConfiguration.Introduction.BackgroundUrl;
3535
if (IsAbsoluteUrl(backgroundUrl))
3636
{
3737
return backgroundUrl;
3838
}
3939

40-
var successful = Uri.TryCreate(new Uri(_navigationManager.BaseUri, UriKind.Absolute), new Uri(backgroundUrl, UriKind.RelativeOrAbsolute), out var uri);
40+
var successful = Uri.TryCreate(new Uri(navigationManager.BaseUri, UriKind.Absolute), new Uri(backgroundUrl, UriKind.RelativeOrAbsolute), out var uri);
4141
return successful ? uri.ToString() : backgroundUrl;
4242
}
4343

@@ -48,7 +48,7 @@
4848

4949
private async Task GetPage(int newPage)
5050
{
51-
_currentPage = await _repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: _appConfiguration.BlogPostsPerPage, page:
51+
currentPage = await repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: appConfiguration.BlogPostsPerPage, page:
5252
newPage);
5353
}
5454
}

LinkDotNet.Blog.Web/Pages/SearchByTag.razor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
@page "/searchByTag/{tag}"
22
@using LinkDotNet.Domain
33
@using LinkDotNet.Infrastructure.Persistence
4-
@inject IRepository _repository
4+
@inject IRepository repository
55

66
<h3>All posts with Tag <em>@Tag</em></h3>
77

8-
@for (var i = 0; i < _blogPosts.Count; i++)
8+
@for (var i = 0; i < blogPosts.Count; i++)
99
{
10-
<ShortBlogPost BlogPost="_blogPosts[i]" UseAlternativeStyle="@(i % 2 != 0)"></ShortBlogPost>
10+
<ShortBlogPost BlogPost="blogPosts[i]" UseAlternativeStyle="@(i % 2 != 0)"></ShortBlogPost>
1111
}
1212

1313
@code {
1414
[Parameter]
1515
public string Tag { get; set; }
1616

17-
IList<BlogPost> _blogPosts = new List<BlogPost>();
17+
IList<BlogPost> blogPosts = new List<BlogPost>();
1818
protected override async Task OnInitializedAsync()
1919
{
2020
Tag = Uri.UnescapeDataString(Tag);
21-
_blogPosts = (await _repository.GetAllAsync(
21+
blogPosts = (await repository.GetAllAsync(
2222
b => b.Tags.Any(t => t.Content == Tag),
2323
b => b.UpdatedDate))
2424
.ToList();

LinkDotNet.Blog.Web/Pages/_Host.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@page "/"
22
@namespace LinkDotNet.Blog.Web.Pages
3-
@inject AppConfiguration _appConfiguration
3+
@inject AppConfiguration appConfiguration
44
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
55
@{
66
Layout = null;
@@ -11,7 +11,7 @@
1111
<head>
1212
<meta charset="utf-8"/>
1313
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
14-
<title>@_appConfiguration.BlogName</title>
14+
<title>@appConfiguration.BlogName</title>
1515
<base href="~/"/>
1616
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
1717
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">

LinkDotNet.Blog.Web/Shared/Admin/BlogPostAdminActions.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@using LinkDotNet.Infrastructure.Persistence
2-
@inject NavigationManager _navigationManager
3-
@inject IToastService _toastService
4-
@inject IRepository _repository
2+
@inject NavigationManager navigationManager
3+
@inject IToastService toastService
4+
@inject IRepository repository
55

66
<AuthorizeView>
77
<div class="blogpost-admin">
@@ -24,9 +24,9 @@
2424

2525
private async Task DeleteBlogPostAsync()
2626
{
27-
await _repository.DeleteAsync(BlogPostId);
28-
_toastService.ShowSuccess("The Blog Post was successfully deleted");
29-
_navigationManager.NavigateTo("/");
27+
await repository.DeleteAsync(BlogPostId);
28+
toastService.ShowSuccess("The Blog Post was successfully deleted");
29+
navigationManager.NavigateTo("/");
3030
}
3131

3232
private void ShowConfirmDialog()
@@ -36,7 +36,7 @@
3636

3737
private void EditBlogPost()
3838
{
39-
_navigationManager.NavigateTo($"update/{BlogPostId}");
39+
navigationManager.NavigateTo($"update/{BlogPostId}");
4040
}
4141

4242
}

LinkDotNet.Blog.Web/Shared/Admin/CreateNewBlogPost.razor

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,48 @@
55

66
<div class="content-area">
77
<div class="new-content">
8-
<EditForm Model="@_model" OnValidSubmit="OnValidBlogPostCreatedAsync">
8+
<EditForm Model="@model" OnValidSubmit="OnValidBlogPostCreatedAsync">
99
<DataAnnotationsValidator />
1010
<ValidationSummary />
1111
<div class="mb-3">
1212
<label for="title">Title</label>
13-
<InputText class="form-control" id="title" @bind-Value="_model.Title" />
13+
<InputText class="form-control" id="title" @bind-Value="model.Title" />
1414
</div>
1515
<div class="mb-3">
1616
<label for="short">Short Description</label>
17-
<InputTextArea class="form-control" id="short" @bind-Value="_model.ShortDescription" rows="4"/>
17+
<InputTextArea class="form-control" id="short" @bind-Value="model.ShortDescription" rows="4"/>
1818
</div>
1919
<div class="mb-3">
2020
<label for="content">Content</label>
21-
<InputTextArea class="form-control" id="content" @bind-Value="_model.Content" rows="10" />
21+
<InputTextArea class="form-control" id="content" @bind-Value="model.Content" rows="10" />
2222
@* <small id="content" class="form-text text-muted">Drag and drop images to upload and insert picture.</small> *@
2323
</div>
2424
<div class="mb-3">
2525
<label for="preview">Preview-Url</label>
26-
<InputText class="form-control" id="preview" @bind-Value="_model.PreviewImageUrl"/>
26+
<InputText class="form-control" id="preview" @bind-Value="model.PreviewImageUrl"/>
2727
</div>
2828
<div class="form-check">
29-
<InputCheckbox class="form-check-input" id="published" @bind-Value="_model.IsPublished" />
29+
<InputCheckbox class="form-check-input" id="published" @bind-Value="model.IsPublished" />
3030
<label class="form-check-label" for="published">Publish</label><br/>
3131
<small id="published" class="form-text text-muted">If this blog post is only draft uncheck the box</small>
3232
</div>
3333
<div class="mb-3">
3434
<label for="tags">Tags</label>
35-
<InputText class="form-control" id="tags" @bind-Value="_model.Tags"/>
35+
<InputText class="form-control" id="tags" @bind-Value="model.Tags"/>
3636
</div>
3737
<button class="btn btn-primary" type="submit">Submit</button>
3838
</EditForm>
3939
</div>
4040
<div class="preview">
4141
<div>
4242
<header>
43-
<h1>@_model.Title</h1>
43+
<h1>@model.Title</h1>
4444
</header>
4545
<div>
46-
@(RenderMarkupString(_model.ShortDescription))
46+
@(RenderMarkupString(model.ShortDescription))
4747
</div>
4848
<div>
49-
@(RenderMarkupString(_model.Content))
49+
@(RenderMarkupString(model.Content))
5050
</div>
5151
</div>
5252
</div>
@@ -64,7 +64,7 @@
6464
[Parameter]
6565
public bool ClearAfterCreated { get; set; } = true;
6666

67-
private CreateNewModel _model = new();
67+
private CreateNewModel model = new();
6868

6969
protected override void OnParametersSet()
7070
{
@@ -73,20 +73,20 @@
7373
return;
7474
}
7575

76-
_model = CreateNewModel.FromBlogPost(BlogPost);
76+
model = CreateNewModel.FromBlogPost(BlogPost);
7777
}
7878

7979
private async Task OnValidBlogPostCreatedAsync()
8080
{
81-
await OnBlogPostCreated.InvokeAsync(_model.ToBlogPost());
81+
await OnBlogPostCreated.InvokeAsync(model.ToBlogPost());
8282
ClearModel();
8383
}
8484

8585
private void ClearModel()
8686
{
8787
if (ClearAfterCreated)
8888
{
89-
_model = new CreateNewModel();
89+
model = new CreateNewModel();
9090
}
9191
}
9292
}

LinkDotNet.Blog.Web/Shared/InputTextAreaDragAndDropFile.razor

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div>
77
<InputTextArea
88
@attributes="AdditionalAttributes"
9-
class="@_cssClass"
9+
class="@CssClass"
1010
@bind-Value="@BindingValue"
1111
ondragover="event.stopPropagation(); event.preventDefault();"
1212
ondragstart="event.stopPropagation(); event.preventDefault();"
@@ -18,20 +18,20 @@
1818
</div>
1919

2020
@code {
21-
private string _dropClass = string.Empty;
22-
private string _otherClasses = string.Empty;
23-
private string _cssClass => _dropClass + " " + _otherClasses;
21+
private string dropClass = string.Empty;
22+
private string otherClasses = string.Empty;
23+
private string CssClass => dropClass + " " + otherClasses;
2424

25-
private string _value;
25+
private string value;
2626

2727
[Parameter]
2828
public string BindingValue
2929
{
30-
get => _value;
30+
get => value;
3131
set
3232
{
33-
if (_value == value ) return;
34-
_value = value;
33+
if (this.value == value ) return;
34+
this.value = value;
3535
BindingValueChanged.InvokeAsync(value);
3636
}
3737
}
@@ -46,24 +46,24 @@
4646
{
4747
if (AdditionalAttributes != null && AdditionalAttributes.ContainsKey("class"))
4848
{
49-
_otherClasses = AdditionalAttributes["class"].ToString();
49+
otherClasses = AdditionalAttributes["class"].ToString();
5050
}
5151
}
5252

5353
private void HandleDrop(DragEventArgs args)
5454
{
55-
_dropClass = string.Empty;
55+
dropClass = string.Empty;
5656
//// This will only work with .NET 6
5757
// var files = args.DataTransfer.Files;
5858
}
5959

6060
private void HandleDragEnter()
6161
{
62-
_dropClass = "can-drop";
62+
dropClass = "can-drop";
6363
}
6464

6565
private void HandleDragLeave()
6666
{
67-
_dropClass = string.Empty;
67+
dropClass = string.Empty;
6868
}
6969
}

0 commit comments

Comments
 (0)