I have created a WEB API
in which I am sending a serial number
and a date time
. In result it gives me the last/latest record value.
What I have done
Below is my controller code
var dateTime = dt.ToString(); // dt is the user sent date time
var result = medEntitites.tj_xhqd.Where(m => m.zdjh == msn) // msn is the serial number
.OrderByDescending(o => o.sjsj)
.Select(s => s.sjsj)//sjsj is datetime in DB
.First().ToString();
I am testing the API
via Postman
. Date time sent by me is in T
format like 2017-10-22T13:30:20
and in controller the date time is 10/22/2017 1:30:20 PM
In response result
the date time getting the last/latest record which is 10/21/2017 6:15:08 PM
API URL: http://localhost:14909/api/meters/GetByMsn/002999000536/2017-10-22T13:30:20
What I want to do?
Now I want to compare the user sent
date time with resulted
date time in such a way the resulted date time is in within the 10 minutes
time span of user sent date time considering the date is same i.e. If the resulted date time is within the 10 minutes time span of the current date time then it will send a YES
response other wise NO
What I know?
I know how to add or subtract minutes
and how to compare two date times, also I know how to set a response on the basis of result.
The problem I am facing is to check with the time span
Any help would be highly appreciated.