Hi,
I've a class model : public DateTime DateSolde { get; set; } ;
I would like to transform this class model by ; public DateTime? DateSolde { get; set; } ;
I've also IActionResult in controller.
public IActionResult MonthlyStats()
{
int numberecr = context.Developers.Count();
int calculN = context.Developers.Count(number => number.DateSolde > number.DateSoldePr && number.Statut == "Close");
int open = context.Developers.Count(a => a.DateCrea.Month == DateTime.Today.Month);
int close = context.Developers.Count(a => a.DateSolde.Month == DateTime.Today.Month && a.DateSolde.Year == _currentYear);
double data = Math.Round(((double)calculN) / numberecr, 1);
var stats = new
{
NombreECR = calculN,
Ratio = data,
EcrTotal = numberecr,
OpenECR = open,
CloseECR = close
};
return Ok(JsonSerializer.Serialize(stats, new JsonSerializerOptions
{
PropertyNamingPolicy = null
}));
}
But when I put DateTime? I received the message
DateTime?' does not contain a definition for 'Year' and no accessible 'Year' extension method accepting a first argument of type 'DateTime?' was found (is a using directive or >assembly reference missing?) WebApp3.Server
It's same things for month.
Why I received this message?
I need to put DateTime? because I use DatePicker and it's necessary to have it.
thanks in advance to your answer