From f8db4ad48a67f89bfac708cbbe357fc8bbbc5ce2 Mon Sep 17 00:00:00 2001 From: Khanbala Rashidov <50279392+KhanbalaRashidov@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:51:08 +0400 Subject: [PATCH] Update --- .../Controllers/WeatherForecastController.cs | 9 ++------- .../Controllers/WeatherForecastController.cs | 9 ++------- .../WebSampleApp/CustomHealthCheck.cs | 17 ++++------------- .../ASPNETCore/WebSampleApp/CustomReadyCheck.cs | 12 ++---------- .../Blazor.ComponentsSample/Pages/Counter.razor | 5 +---- .../Pages/CounterWithService.razor | 5 +---- .../Blazor.ComponentsSample/Pages/Editor.razor | 5 +---- .../Pages/FetchData.razor | 6 ++---- .../Data/WeatherForecastService.cs | 4 +--- .../Blazor.ServerSample/Pages/Counter.razor | 5 +---- .../Blazor.ServerSample/Pages/FetchData.razor | 5 +---- .../Client/Pages/Counter.razor | 5 +---- .../Client/Pages/FetchData.razor | 6 ++---- .../Controllers/WeatherForecastController.cs | 9 ++------- 14 files changed, 23 insertions(+), 79 deletions(-) diff --git a/3_Web/ASPNETCore/AngularSample/Controllers/WeatherForecastController.cs b/3_Web/ASPNETCore/AngularSample/Controllers/WeatherForecastController.cs index a539314e..e01b8a2d 100644 --- a/3_Web/ASPNETCore/AngularSample/Controllers/WeatherForecastController.cs +++ b/3_Web/ASPNETCore/AngularSample/Controllers/WeatherForecastController.cs @@ -13,20 +13,15 @@ public class WeatherForecastController : ControllerBase private readonly ILogger _logger; - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } + public WeatherForecastController(ILogger logger) => _logger = logger; [HttpGet] public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast + => Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] }) .ToArray(); - } } diff --git a/3_Web/ASPNETCore/ReactSample/Controllers/WeatherForecastController.cs b/3_Web/ASPNETCore/ReactSample/Controllers/WeatherForecastController.cs index a75250f8..40c34222 100644 --- a/3_Web/ASPNETCore/ReactSample/Controllers/WeatherForecastController.cs +++ b/3_Web/ASPNETCore/ReactSample/Controllers/WeatherForecastController.cs @@ -13,20 +13,15 @@ public class WeatherForecastController : ControllerBase private readonly ILogger _logger; - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } + public WeatherForecastController(ILogger logger) => _logger = logger; [HttpGet] public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast + => Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] }) .ToArray(); - } } diff --git a/3_Web/ASPNETCore/WebSampleApp/CustomHealthCheck.cs b/3_Web/ASPNETCore/WebSampleApp/CustomHealthCheck.cs index b2c616bb..72cbb712 100644 --- a/3_Web/ASPNETCore/WebSampleApp/CustomHealthCheck.cs +++ b/3_Web/ASPNETCore/WebSampleApp/CustomHealthCheck.cs @@ -4,20 +4,11 @@ namespace WebSampleApp; -public class CustomHealthCheck : IHealthCheck +public class CustomHealthCheck(HealthSample healthSample) : IHealthCheck { - private readonly HealthSample _healthSample; - public CustomHealthCheck(HealthSample healthSample) => _healthSample = healthSample; + private readonly HealthSample _healthSample = healthSample; public Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) - { - if (_healthSample.IsHealthy) - { - return Task.FromResult(HealthCheckResult.Healthy("healthy")); - } - else - { - return Task.FromResult(HealthCheckResult.Unhealthy("unhealthy")); - } - } + => _healthSample.IsHealthy ? Task.FromResult(HealthCheckResult.Healthy("healthy")) + : Task.FromResult(HealthCheckResult.Unhealthy("unhealthy")); } diff --git a/3_Web/ASPNETCore/WebSampleApp/CustomReadyCheck.cs b/3_Web/ASPNETCore/WebSampleApp/CustomReadyCheck.cs index 561ee329..724f4c14 100644 --- a/3_Web/ASPNETCore/WebSampleApp/CustomReadyCheck.cs +++ b/3_Web/ASPNETCore/WebSampleApp/CustomReadyCheck.cs @@ -7,14 +7,6 @@ namespace WebSampleApp; public class CustomReadyCheck(HealthSample healthSample) : IHealthCheck { public Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) - { - if (healthSample.IsReady) - { - return Task.FromResult(HealthCheckResult.Healthy("healthy")); - } - else - { - return Task.FromResult(HealthCheckResult.Unhealthy("unhealthy")); - } - } + => healthSample.IsReady ? Task.FromResult(HealthCheckResult.Healthy("healthy")) + : Task.FromResult(HealthCheckResult.Unhealthy("unhealthy")); } diff --git a/3_Web/Blazor/Blazor.ComponentsSample/Pages/Counter.razor b/3_Web/Blazor/Blazor.ComponentsSample/Pages/Counter.razor index 6d797b2b..b9082fab 100644 --- a/3_Web/Blazor/Blazor.ComponentsSample/Pages/Counter.razor +++ b/3_Web/Blazor/Blazor.ComponentsSample/Pages/Counter.razor @@ -14,8 +14,5 @@ [Parameter] public int Incrementor { get; set; } = 1; - private void IncrementCount() - { - currentCount += Incrementor; - } + private void IncrementCount() => currentCount += Incrementor; } diff --git a/3_Web/Blazor/Blazor.ComponentsSample/Pages/CounterWithService.razor b/3_Web/Blazor/Blazor.ComponentsSample/Pages/CounterWithService.razor index c95631c6..594bd864 100644 --- a/3_Web/Blazor/Blazor.ComponentsSample/Pages/CounterWithService.razor +++ b/3_Web/Blazor/Blazor.ComponentsSample/Pages/CounterWithService.razor @@ -11,8 +11,5 @@ [Parameter] public int Incrementor { get; set; } = 1; - private void IncrementCount() - { - CounterService.Counter += Incrementor; - } + private void IncrementCount() => CounterService.Counter += Incrementor; } diff --git a/3_Web/Blazor/Blazor.ComponentsSample/Pages/Editor.razor b/3_Web/Blazor/Blazor.ComponentsSample/Pages/Editor.razor index 284bc8b3..54315e23 100644 --- a/3_Web/Blazor/Blazor.ComponentsSample/Pages/Editor.razor +++ b/3_Web/Blazor/Blazor.ComponentsSample/Pages/Editor.razor @@ -34,8 +34,5 @@ private BookEditModel bookEditModel = new(); private string validText = string.Empty; - private void HandleValidSubmit(EditContext context) - { - validText = "Input is valid, ready to send it to the server"; - } + private void HandleValidSubmit(EditContext context) => validText = "Input is valid, ready to send it to the server"; } diff --git a/3_Web/Blazor/Blazor.ComponentsSample/Pages/FetchData.razor b/3_Web/Blazor/Blazor.ComponentsSample/Pages/FetchData.razor index 7d004a5f..3418f535 100644 --- a/3_Web/Blazor/Blazor.ComponentsSample/Pages/FetchData.razor +++ b/3_Web/Blazor/Blazor.ComponentsSample/Pages/FetchData.razor @@ -39,10 +39,8 @@ else @code { private WeatherForecast[]? forecasts; - protected override async Task OnInitializedAsync() - { - forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); - } + protected override async Task OnInitializedAsync() + => forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); public class WeatherForecast { diff --git a/3_Web/Blazor/Blazor.ServerSample/Data/WeatherForecastService.cs b/3_Web/Blazor/Blazor.ServerSample/Data/WeatherForecastService.cs index c383a7ba..da45a9cd 100644 --- a/3_Web/Blazor/Blazor.ServerSample/Data/WeatherForecastService.cs +++ b/3_Web/Blazor/Blazor.ServerSample/Data/WeatherForecastService.cs @@ -8,12 +8,10 @@ public class WeatherForecastService }; public Task GetForecastAsync(DateTime startDate) - { - return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast + => Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = startDate.AddDays(index), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] }).ToArray()); - } } diff --git a/3_Web/Blazor/Blazor.ServerSample/Pages/Counter.razor b/3_Web/Blazor/Blazor.ServerSample/Pages/Counter.razor index ef23cb31..41372477 100644 --- a/3_Web/Blazor/Blazor.ServerSample/Pages/Counter.razor +++ b/3_Web/Blazor/Blazor.ServerSample/Pages/Counter.razor @@ -11,8 +11,5 @@ @code { private int currentCount = 0; - private void IncrementCount() - { - currentCount++; - } + private void IncrementCount() => currentCount++; } diff --git a/3_Web/Blazor/Blazor.ServerSample/Pages/FetchData.razor b/3_Web/Blazor/Blazor.ServerSample/Pages/FetchData.razor index 54093ebf..96b14c49 100644 --- a/3_Web/Blazor/Blazor.ServerSample/Pages/FetchData.razor +++ b/3_Web/Blazor/Blazor.ServerSample/Pages/FetchData.razor @@ -41,8 +41,5 @@ else @code { private WeatherForecast[]? forecasts; - protected override async Task OnInitializedAsync() - { - forecasts = await ForecastService.GetForecastAsync(DateTime.Now); - } + protected override async Task OnInitializedAsync() => forecasts = await ForecastService.GetForecastAsync(DateTime.Now); } diff --git a/3_Web/Blazor/Blazor.WasmSample/Client/Pages/Counter.razor b/3_Web/Blazor/Blazor.WasmSample/Client/Pages/Counter.razor index ef23cb31..41372477 100644 --- a/3_Web/Blazor/Blazor.WasmSample/Client/Pages/Counter.razor +++ b/3_Web/Blazor/Blazor.WasmSample/Client/Pages/Counter.razor @@ -11,8 +11,5 @@ @code { private int currentCount = 0; - private void IncrementCount() - { - currentCount++; - } + private void IncrementCount() => currentCount++; } diff --git a/3_Web/Blazor/Blazor.WasmSample/Client/Pages/FetchData.razor b/3_Web/Blazor/Blazor.WasmSample/Client/Pages/FetchData.razor index 41ff44d9..e3762b50 100644 --- a/3_Web/Blazor/Blazor.WasmSample/Client/Pages/FetchData.razor +++ b/3_Web/Blazor/Blazor.WasmSample/Client/Pages/FetchData.razor @@ -40,8 +40,6 @@ else @code { private WeatherForecast[]? forecasts; - protected override async Task OnInitializedAsync() - { - forecasts = await Http.GetFromJsonAsync("WeatherForecast"); - } + protected override async Task OnInitializedAsync() + => forecasts = await Http.GetFromJsonAsync("WeatherForecast"); } diff --git a/3_Web/Blazor/Blazor.WasmSample/Server/Controllers/WeatherForecastController.cs b/3_Web/Blazor/Blazor.WasmSample/Server/Controllers/WeatherForecastController.cs index bab956a9..e45c00ae 100644 --- a/3_Web/Blazor/Blazor.WasmSample/Server/Controllers/WeatherForecastController.cs +++ b/3_Web/Blazor/Blazor.WasmSample/Server/Controllers/WeatherForecastController.cs @@ -14,20 +14,15 @@ public class WeatherForecastController : ControllerBase private readonly ILogger _logger; - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } + public WeatherForecastController(ILogger logger) => _logger = logger; [HttpGet] public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast + => Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateTime.Now.AddDays(index), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] }) .ToArray(); - } }