Skip to content

Commit 352a655

Browse files
refactor: simplify namespace declarations and improve code formatting
1 parent 0aeb52f commit 352a655

File tree

4 files changed

+39
-40
lines changed

4 files changed

+39
-40
lines changed

SampleApp/BackEnd/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Scalar.AspNetCore;
2+
13
var builder = WebApplication.CreateBuilder(args);
24

35
// Add services to the container.
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
namespace FrontEnd.Data
1+
namespace FrontEnd.Data;
2+
3+
public class WeatherForecast
24
{
3-
public class WeatherForecast
4-
{
5-
public DateOnly Date { get; set; }
5+
public DateOnly Date { get; set; }
66

7-
public int TemperatureC { get; set; }
7+
public int TemperatureC { get; set; }
88

9-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1010

11-
public string? Summary { get; set; }
12-
}
13-
}
11+
public string? Summary { get; set; }
12+
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
namespace FrontEnd.Data
2-
{
3-
public class WeatherForecastClient
4-
{
5-
private HttpClient _httpClient;
6-
private ILogger<WeatherForecastClient> _logger;
1+
namespace FrontEnd.Data;
72

8-
public WeatherForecastClient(HttpClient httpClient, ILogger<WeatherForecastClient> logger)
9-
{
10-
_httpClient = httpClient;
11-
_logger = logger;
12-
}
3+
public class WeatherForecastClient
4+
{
5+
private HttpClient _httpClient;
6+
private ILogger<WeatherForecastClient> _logger;
137

14-
public async Task<WeatherForecast[]> GetForecastAsync(DateTime? startDate)
15-
=> await _httpClient.GetFromJsonAsync<WeatherForecast[]>($"WeatherForecast?startDate={startDate}");
8+
public WeatherForecastClient(HttpClient httpClient, ILogger<WeatherForecastClient> logger)
9+
{
10+
_httpClient = httpClient;
11+
_logger = logger;
1612
}
17-
}
13+
14+
public async Task<WeatherForecast[]> GetForecastAsync(DateTime? startDate)
15+
=> await _httpClient.GetFromJsonAsync<WeatherForecast[]>($"WeatherForecast?startDate={startDate}") ?? [];
16+
}

SampleApp/FrontEnd/Pages/Error.cshtml.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
using Microsoft.AspNetCore.Mvc.RazorPages;
33
using System.Diagnostics;
44

5-
namespace FrontEnd.Pages
5+
namespace FrontEnd.Pages;
6+
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
610
{
7-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8-
[IgnoreAntiforgeryToken]
9-
public class ErrorModel : PageModel
10-
{
11-
public string? RequestId { get; set; }
11+
public string? RequestId { get; set; }
1212

13-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1414

15-
private readonly ILogger<ErrorModel> _logger;
15+
private readonly ILogger<ErrorModel> _logger;
1616

17-
public ErrorModel(ILogger<ErrorModel> logger)
18-
{
19-
_logger = logger;
20-
}
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
2121

22-
public void OnGet()
23-
{
24-
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25-
}
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
2625
}
27-
}
26+
}

0 commit comments

Comments
 (0)