title: How do i write code in ASP.NET MVC to check whether user accepeted terms and condition
body: <p>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 <strong>Appterms</strong>, in which I have field called <strong>TermsAccepted</strong> and <strong>Date</strong>. I also have other fields in Appterms table such as  <strong>GatewayUserId</strong> and <strong>termId</strong>. ' GatewayUserID has ID of registered users and termId is primary key. 'Termsaccepted' field is of bit type.</p>
  
  <p>I tried to follow custom attribute function which is posted in this post 
  <a href="https://stackoverflow.com/questions/11967981/mvc-3-how-can-i-make-a-user-view-a-warning-disclaimer-screen">MVC 3 How can I make a user view a warning/disclaimer screen</a> but not able to implement as per my needs.</p>
  
  <p>I am using this post <a href="https://stackoverflow.com/questions/924692/how-do-you-get-the-userid-of-a-user-object-in-asp-net-mvc">Getting current user id</a> to get id of current user. So after this how can i return 0 or 1 to check they accepted terms and condition.</p>
  
  <p>This is the code snippet I am trying to use :</p>
  
  <pre><code>[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
      }
   }
  </code></pre>
  
  <p>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.</p>
  
  <p>Any help??
  Thanks..</p>