As a input i am getting startDate and endDate. I have to do a linq query from client side to check if there is any existing entry in DB within this time.
For example, in my DB if i have an entry with StartDate of 2018-01-05 and enddate of 2018-01-09 and user tries to put another entry with start date of 2018-01-04 and enddate of 2018-01-06 i should not allow that, because in my DB i have already an entry that is common within this time range. Here is my code
 var stDate = dbcontext.tables.Where( st => 
                             st.StartDate <= UserStartDate && st.EndDate >= UserEndDate && st.Status == "Queued" ||
                             st.StartDate >= UserStartDate && st.EndDate >= UserEndDate && st.Status == "Queued" ||
                             st.StartDate <= UserStartDate && st.EndDate <= UserEndDate && st.Status == "Queued" ||
                             st.StartDate >= UserStartDate && st.EndDate <= UserEndDate && st.Status == "Queued").ToList();
                if (stDate.Count >0 )
                {
                    //notification to user("There is an existing request within this time range");
                }
                else
                {
                    // do the rest operation
                }
But the problem is if someone tries to enter an entry from 2018-01-09 to 2018-01-10 it falls under 3 condition and application is not taking this entry. Any suggestion for me how can i improve my code?
 
    
 
    