diff --git a/text-counter-razor/Pages/Error.cshtml.cs b/text-counter-razor/Pages/Error.cshtml.cs index 6189b83..9d66b3d 100644 --- a/text-counter-razor/Pages/Error.cshtml.cs +++ b/text-counter-razor/Pages/Error.cshtml.cs @@ -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 _logger; + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - public ErrorModel(ILogger logger) - { - _logger = logger; - } + private readonly ILogger _logger; - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } } } diff --git a/text-counter-razor/Pages/Index.cshtml.cs b/text-counter-razor/Pages/Index.cshtml.cs index 9a4ceda..1f12625 100644 --- a/text-counter-razor/Pages/Index.cshtml.cs +++ b/text-counter-razor/Pages/Index.cshtml.cs @@ -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 _logger; + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.RazorPages; - public IndexModel(ILogger logger) + public class IndexModel : PageModel { - _logger = logger; - } + private readonly ILogger _logger; - public void OnGet() { } + public IndexModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() { } + } } diff --git a/text-counter-razor/Pages/TextCounter.cshtml.cs b/text-counter-razor/Pages/TextCounter.cshtml.cs index e8dc284..a35f84c 100644 --- a/text-counter-razor/Pages/TextCounter.cshtml.cs +++ b/text-counter-razor/Pages/TextCounter.cshtml.cs @@ -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; + } } }