Skip to content

Commit

Permalink
Add namespaces to fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lulunac27a committed Nov 11, 2024
1 parent 60a3b29 commit 05bf1f5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 49 deletions.
39 changes: 20 additions & 19 deletions text-counter-razor/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace text_counter_razor.Pages;

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
namespace text_counter_razor.Pages
{
public string? RequestId { get; set; }
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

private readonly ILogger<ErrorModel> _logger;
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
private readonly ILogger<ErrorModel> _logger;

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
23 changes: 12 additions & 11 deletions text-counter-razor/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace text_counter_razor.Pages;

public class IndexModel : PageModel
namespace text_counter_razor.Pages
{
private readonly ILogger<IndexModel> _logger;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

public IndexModel(ILogger<IndexModel> logger)
public class IndexModel : PageModel
{
_logger = logger;
}
private readonly ILogger<IndexModel> _logger;

public void OnGet() { }
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}

public void OnGet() { }
}
}
41 changes: 22 additions & 19 deletions text-counter-razor/Pages/TextCounter.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

public class TextCounterModel : PageModel
namespace text_counter_razor.Pages
{
[BindProperty]
public string? TextContent { get; set; } //text content string input from text box
public int Characters { get; set; } //number of characters
public int Words { get; set; } //number of words
public int Lines { get; set; } //number of lines
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

public void OnPost()
public class TextCounterModel : PageModel
{
this.TextContent = this.Request.Form["textContent"]; //get text box input
this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text
this.Words =
this.TextContent?.Split(
new char[] { ' ', '\r', '\n' },
StringSplitOptions.RemoveEmptyEntries
).Length ?? 0;
this.Lines =
this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
[BindProperty]
public string? TextContent { get; set; } //text content string input from text box
public int Characters { get; set; } //number of characters
public int Words { get; set; } //number of words
public int Lines { get; set; } //number of lines

public void OnPost()
{
this.TextContent = this.Request.Form["textContent"]; //get text box input
this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text
this.Words =
this.TextContent?.Split(
new char[] { ' ', '\r', '\n' },
StringSplitOptions.RemoveEmptyEntries
).Length ?? 0;
this.Lines =
this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
}
}
}

0 comments on commit 05bf1f5

Please sign in to comment.