25 lines
685 B
C#
25 lines
685 B
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Expose.MyIT.Shared.ViewModels;
|
|
|
|
public record WeatherForecast
|
|
{
|
|
|
|
[JsonConstructor]
|
|
public WeatherForecast(DateOnly Date, int TemperatureC, string? Summary, int TemperatureF)
|
|
{ }
|
|
|
|
public WeatherForecast(Models.WeatherForecast weatherForecast) :
|
|
this(weatherForecast.Date,
|
|
weatherForecast.TemperatureC,
|
|
weatherForecast.Summary,
|
|
weatherForecast.TemperatureF)
|
|
{ }
|
|
|
|
public override string ToString()
|
|
{
|
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
|
return result;
|
|
}
|
|
} |