Hi,
in the startup.cs module of a Blazor server project I declared this endpoint:
endpoints.MapPost("/timestamp/addtimestamp/", (context) =>
{
var timestamp = context.Request.ReadFromJsonAsync<Timestamp>();
(Timestamp ReturnTimestamp, var error) = app.ApplicationServices.GetService<TimestampService>().AddTimestamp(timestamp);
var json = JsonSerializer.Serialize(new { ReturnTimestamp = ReturnTimestamp, error = error });
return context.Response.WriteAsync(json);
});
the AddTimestamp service should receive a TimeStamp object as "parameter":
public (Timestamp, Error) AddTimestamp(Timestamp timestamp)
{
...
}
I get this error:
Error CS1503 Argument 1: cannot convert from 'System.Threading.Tasks.ValueTask<TSNet.BO.Timestamp?>' to 'TSNet.BO.Timestamp'
the "timestamp" object, that is passed as a parameter to AddTimestamp servize, is not Timestamp obejct
How can I "convert" it?
Best
Stefano