In my ASP.NET MVC project I need to write code to check for users whether they accept terms and condition. I am using Entity framework and Database first approach. I have Table called Appterms, in which I have field called TermsAccepted and Date. I also have other fields in Appterms table such as GatewayUserId and termId. ' GatewayUserID has ID of registered users and termId is primary key. 'Termsaccepted' field is of bit type.
I tried to follow custom attribute function which is posted in this post MVC 3 How can I make a user view a warning/disclaimer screen but not able to implement as per my needs.
I am using this post Getting current user id to get id of current user. So after this how can i return 0 or 1 to check they accepted terms and condition.
This is the code snippet I am trying to use :
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method,
Inherited = true, AllowMultiple = false)]
public class AcceptedTermsCheck : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Check if AcceptedTC is set to true
// If set, then do nothing
// Otherwise redirect to TC page
}
}
Here to check if user accepted terms, i should return true, that is '1' in my GatewayUserId field, if not it should return false.But I don't know how to do this. And also I got to know I should create session to achieve this task. But never worked on it before.
Any help?? Thanks..