Click here to Skip to main content
15,883,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a database table which has a list of professor, from my website users can search and select a professor for a day.
As soon as a student select a professor I don't want that professor to be in the list of professors for other users and if that user doesn't confirm to go with this professor then again he should be displayed in the list.
Here is an example, I have four professors P1, P2,P3 and P4
All users can see all of them
now a user U1 select P2 so all other users should see P1,P3 and P4
Also, on next page if user U1 doesn't confirm then I have to add that P2 back to the list.
How can I achieve this in asp.net 4.0 with Sql server 2008
Posted

1 solution

You haven't said what database access technology you're using so I'm just going to show you the raw SQL. If you are using something specific like ADO.net, LinqtoSQL, Entity Framework, NHibernate etc then you really should mention these things in your question as it often makes all the difference.

Add a bit\Boolean "locked" field to the Professor database and when you retrieve the professor

SQL
UPDATE Professor SET Locked = 1 WHERE ID = 123

SELECT * From Professor WHERE ID = 123


Then when the user chooses to not accept that professor to view

SQL
UPDATE Professor SET Locked = 0 WHERE ID = 123


You then update the sql that shows the list of available professors to exclude those that are locked

SQL
SELECT * From Professor WHERE Locked = 0
 
Share this answer
 
Comments
nikhil choudhry 27-Mar-15 10:20am    
Thanks, how can we update the status back to "Y" if user just close the browser without confirming or session expires?
F-ES Sitecore 27-Mar-15 10:52am    
You can't, that's why you don't do things like this, but you'll only learn that from experience :)

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