Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
User1 has the following fieldnames enabled:

TrialStartDate: 26/05/2013
TrialExpiryDate: 31/05/2013
WIC_ALL: true
Price_StartDate: 28/05/2013
Price_ExpiryDate: 31/05/2013

If User1 has trialStart and trialExpiry Date setup, then user becomes a newsUser. However , when the user1 also has wic_all, PriceStart and PriceExpiry Date setup too, then user1 becomes full user, making it overide the (NewsTrials) query.

My issue is that I am unable to login user1 as FullUser using the (full-test) query. I would like to know how can overide the newsTrial query?

Please help.
C#
public UserDetail NewsTrial(string username, string password)
{

    var query = from s in db.Subscriptions
                join u in db.UserDetails on s.sUID equals u.uID
                where s.sTrialExpiryDate >= DateTime.Now &&
                s.sPID.Value == 163 &&
                u.uUsername == username &&
                u.uPassword == password
                select u; //
    return query.FirstOrDefault();

}

public UserDetail full_test(string username, string password)
{
    var query = from s in db.Subscriptions
                join u in db.UserDetails on s.sUID equals u.uID
                where s.sPrice_ExpiryDate >= DateTime.Now &&
                s.sPID.Value == 163 &&
                s.sWIC_All.Value == true &&
                u.uUsername == username &&
                u.uPassword == password
                select u;
    return query.FirstOrDefault();
}


Many thanks.
Posted
Updated 6-Jun-14 4:32am
v3
Comments
ZurdoDev 6-Jun-14 9:54am    
I don't understand your question.
miss786 6-Jun-14 10:27am    
Apology for not making question clearer. when user1 has only trialexpiry and trialstart date, then user1 is known as newsUser, however when the user1 also has wic_all,priceStart and priceExpiryDate, then the user1 becomes a full user. Currently, I cannot get the user1 to login as full-test, this is my current issue at the moment. please advice, if possible.
_Maxxx_ 6-Jun-14 10:38am    
Are you simply saying that passing the same username and password to each of the two methods, NewsTrial returns a record and full_test returns null?
If that is the case, I can't see anything wrong with the query, so it is likely a problem with the data
I would run in debug, break on the query and check the data at runtime.
If it still looks OK I would try removing lines from select 1 by 1 until you DO get a record, and then you know which bit is failing
miss786 6-Jun-14 10:46am    
Many thanks for your feedback.

I have a web-api application, where I have the following two queries set-up, newsTrial(query), leads to [Newspage] and fullTest(query), leads to [fullPage]. when I login as user1, it leads to [Newspage] instead of [fullPage]. However, I have tested the user1 against the following sql query and it shows user1 records in the sql query below, but using the trial sql query.

select u.[uID], u.[uUsername], u.[uPassword], s.[sPriceABS_ExpiryDate]
from [dbo].[UserDetails] u
join [dbo].[Subscriptions] s
on u.uID = s.sUID
where s.[sPrice_ExpiryDate]>= getdate()
and s.[sWIC_All] = '1'
and s.sPID = '163'
_Maxxx_ 6-Jun-14 10:58am    
Given that the dates you show in your sample data are all in 2013, that seems unlikely!
As I said, I would debug it to try to find out what is happening -

One thought does occur - if BOTH queries return a record, then the page you go to will depend on the order in which you run them - so perhaps run the full test first?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900