Dates Comparison c #

2

My question is the following.

  

Ineedtodisplay2statusesonapagethatwouldbePrimeiroandAlterado,wherethefirstlineofsqlwiththedateof2018-03-0510:24:55.787receivesstatusPrimeiroandthesecondlineofsqlwithdate2018-03-0510:30:09.727receivesstatusAlteradoandthethirdlinereceivesstatusAtivobutisalreadyworkingasyoucanseeinthecodebelow.

<tdclass="text-center">
  @if (item.StatPree == 1)
  {
      <a class="ui teal label">Ativo</a>
  }
  else {
      if (...)
      {
          <a class="ui yellow label">Primeiro</a>
      }
      else
      {
          <a class="ui orange label">Alterado</a>
      }
  }
</td>

Variable is public DateTime? DataEdicao { get; set; }

    
asked by anonymous 05.03.2018 / 15:14

1 answer

2

You can compare the date, and if the date is equal to the lowest date of the same PatientId, it is the first, if not, change:

Example:

if (item.DataEdicao == Model.Where(x=> x.PatientId == item.PatientId).Min(x=> x.DataEdicao))
{
  <a class="ui yellow label">Primeiro</a>
}
else
{
   <a class="ui orange label">Alterado</a>
}
    
05.03.2018 / 15:41