Skip to content

Commit

Permalink
Rename to Forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 28, 2024
1 parent ab86e20 commit 527ab5e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions MyApp.Client/src/dtos.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Options:
Date: 2024-02-18 12:11:40
Date: 2024-02-28 19:37:38
Version: 8.13
Tip: To override a DTO option, remove "//" prefix before updating
BaseUrl: https://localhost:5001
Expand Down Expand Up @@ -229,14 +229,14 @@ export class Booking extends AuditBase
public constructor(init?: Partial<Booking>) { super(init); (Object as any).assign(this, init); }
}

export class WeatherForecast implements IGet
export class Forecast implements IGet
{
public date: string;
public temperatureC: number;
public summary?: string;
public temperatureF: number;

public constructor(init?: Partial<WeatherForecast>) { (Object as any).assign(this, init); }
public constructor(init?: Partial<Forecast>) { (Object as any).assign(this, init); }
}

export class PageStats
Expand Down Expand Up @@ -440,14 +440,14 @@ export class Hello implements IReturn<HelloResponse>, IGet
public createResponse() { return new HelloResponse(); }
}

export class GetWeatherForecast implements IReturn<WeatherForecast[]>, IGet
export class GetWeatherForecast implements IReturn<Forecast[]>, IGet
{
public date?: string;

public constructor(init?: Partial<GetWeatherForecast>) { (Object as any).assign(this, init); }
public getTypeName() { return 'GetWeatherForecast'; }
public getMethod() { return 'GET'; }
public createResponse() { return new Array<WeatherForecast>(); }
public createResponse() { return new Array<Forecast>(); }
}

export class AdminData implements IReturn<AdminDataResponse>, IGet
Expand Down
10 changes: 5 additions & 5 deletions MyApp.Client/src/pages/weather.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { useState, useEffect } from "react"
import LayoutPage from "@/components/LayoutPage"
import SrcPage from "@/components/SrcPage"
import { useClient } from "@/gateway";
import { GetWeatherForecast, WeatherForecast } from "@/dtos"
import { useClient } from "@/gateway"
import { GetWeatherForecast, Forecast } from "@/dtos"
import { columnDefs, DataTable, getCoreRowModel } from "@/components/DataTable.tsx"

export default (): JSX.Element => {
const [results, setResults] = useState<WeatherForecast[]>([])
const client = useClient()
const [forecasts, setForecasts] = useState<Forecast[]>([])

useEffect(() => {
(async () => {
const api = await client.api(new GetWeatherForecast())
if (api.succeeded) {
setResults(api.response!)
setForecasts(api.response!)
}
})()
}, [])
Expand All @@ -26,7 +26,7 @@ export default (): JSX.Element => {
})

return (<LayoutPage title="Weather">
<DataTable columns={columns} data={results} getCoreRowModel={getCoreRowModel()} />
<DataTable columns={columns} data={forecasts} getCoreRowModel={getCoreRowModel()} />
<div className="mt-8 flex justify-center gap-x-4">
<SrcPage path="weather.tsx" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion MyApp.ServiceInterface/MyServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public object Any(Hello request)
public object Any(GetWeatherForecast request)
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast(
return Enumerable.Range(1, 5).Select(index => new Forecast(
Date: (request.Date ?? DateOnly.FromDateTime(DateTime.Now)).AddDays(index),
TemperatureC: rng.Next(-20, 55),
Summary: summaries[rng.Next(summaries.Length)]
Expand Down
4 changes: 2 additions & 2 deletions MyApp.ServiceModel/Hello.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class HelloResponse
public required string Result { get; set; }
}

public class GetWeatherForecast : IGet, IReturn<WeatherForecast[]>
public class GetWeatherForecast : IGet, IReturn<Forecast[]>
{
public required DateOnly? Date { get; set; }
}

public record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) : IGet, IReturn<WeatherForecast[]>
public record Forecast(DateOnly Date, int TemperatureC, string? Summary) : IGet, IReturn<Forecast[]>
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

0 comments on commit 527ab5e

Please sign in to comment.