Method/Algorithm for fetching an ASP.NET MVC date

Asked

Viewed 33 times

-1

I have the following problem: I’m trying to get a date. I just can’t figure out an algorithm for this. I have a class called RequisicaoDeVeiculo, this class has the attribute DataEHoraDoServico, and I have another class that MovimentacaoDeVeiculo, which has the attribute DataEHoraDaChegada, and the class veiculo. The class RequisicaoDeVeiculo has the classes MovimentacaoDeVeiculo and veiculo. Suppose a user made a RequisicaoDeVeiculo, and went on a mission in a Veículo x on the day 01/08/2018 that is to say, DataEHoraDoServico= 01/08/2018, this vehicle returned on the day 05/08/2018, DataEHoraDaChegada= 05/08/2018. Suppose there was a fine for this vehicle X, and the date of the fine is day 03/08/2018. so I want to look at my system, who was on that date, with that vehicle. so I have a form in my system with a date, and a Dropdow, to choose a vehicle. then I typed in my form the following data: data=03/08/2018 and Veículo=X, then I have an action that gets the data and IdDoVeiculo, and the function thus =>

var BuscarSolicitacaoPorDataEIdDoVeiculo = db.Meucontexto.Where(x => x.DataEHoraDoServico >= data && x.MovimentacaoDeVeiculo.DataEHoraDaChegada <= data && x.IdVeiculo = IdVeiculo); This method is not certain because it only looks for requests that are HIGHER OR EQUAL to date, thus, it seeks only requests that have been made on the day 03/08/2018 or greater. however the DataEHoraDoServicois equal to 01/08/2018. Can someone give me a hand?

1 answer

0


You probably reversed something ,

db.Meucontexto.Where(x =>
       x.IdVeiculo == IdVeiculo
            &&  
     (dataMulta <= x.DataEHoraChegada && dataMulta >= x.DataEHoraServico)
).ToList();
  • Man, thanks a lot, thank you, it really worked. There are times when the brain hangs, and no matter how hard you try, you can’t find a solution. I locked into this simple algorithm.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.