forked from ddrilling/AsbCloudServer
Olga Nemt
b6181ab82f
2. Обновление типа данных поля "Дата отчета" в таблице "Суточный рапорт" (timestamp with time zone изменен на date)
23 lines
651 B
C#
23 lines
651 B
C#
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace AsbCloudWebApi.Converters
|
|
{
|
|
#nullable enable
|
|
public class DateOnlyJsonConverter : JsonConverter<DateOnly>
|
|
{
|
|
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
return DateOnly.FromDateTime(reader.GetDateTime());
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
|
|
{
|
|
var isoDate = value.ToString("O");
|
|
writer.WriteStringValue(isoDate);
|
|
}
|
|
}
|
|
#nullable disable
|
|
}
|