Im playing abit with the .NET minimal API. Trying to catch this exception when Im passing "Price" as a string I've got my DTO as follows:
public record TransactionCreateDto
{
public string Description { get; init; } = String.Empty;
public string Store { get; init; } = String.Empty;
public double Price { get; init; }
public string Date { get; init; } = String.Empty;
public int PaymentTypeId { get; init; }
public int CategoryId { get; init; }
public bool Seen { get; init; }
}
Here is the flow:
...
app.MapPost("/transactions", TransactionsAPI.InsertTransaction);
...
And he insert transaction function:
public static async Task<IResult> InsertTransaction(TransactionCreateDto transactionDto, ITransactionRepository repo)
{
try
{
...
}
catch (Exception ex)
{
...
}
}
Im sure there is a correct way to catch this exception. Thanks alot!