Reputation: 37
How could i know if there's a conflict , example i have here User Start time 7:00 AM End time 12:00 PM. Now if i add new Entry it should always CHECK the time. It shouldn't be the same with the first one. Meaning to say his time should be 12:00 PM Onwards. If his time is between 7-12. Example 11:00 AM this is CONFLICT since the first one has already workd in that time.
To be more clear First entry .7:00 Am-12:00pm Second entry 12:00pm-3pm Third entry 3:00pm-7:00pm And so on. Thank you to those who will help.
Upvotes: 1
Views: 1600
Reputation: 61
Just do some checks on the three dates you are using. You should make an object for this but here is a simple code section of what it should look like.
var start = DateTime.Now;
var end = start.AddHours(3);
var newStart1 = start.AddHours(2);
if(newStart1> start && end<= newStart1)
{
//valid time
}
else
{
throw new Exception("Invalid start time.");
}
Upvotes: 1