/// <summary>
        /// The GetNotificationTemplate method
        /// </summary>
        /// <param name="eventTypeId">The eventTypeId parameter</param>
        /// <param name="notifyType">The notifyType parameter</param>
        /// <returns>The AuthNet.PoC.EventModel.Entities.NotificationTemplate type object</returns>        
        public NotificationTemplate GetNotificationTemplate(int eventTypeId, NotificationTypes notifyType)
        {
            NotificationTemplate notification = new NotificationTemplate();
            string notificationstring = notifyType.ToString();
            string name = string.Empty;
            string sqlquery = "SELECT * from EventType where EventTypeId = " + eventTypeId;
            using (IDataReader reader = ExecuteInlineQueryReader(sqlquery))
            {
                while (reader.Read())
                {
                    name = reader[1].ToString();
                    break;
                }
            }

            sqlquery = "SELECT * from NotificationTemplate where EventType = '" + name + "' AND NotificationType = '" + notificationstring + "'";

            using (IDataReader reader = ExecuteInlineQueryReader(sqlquery))
            {
                while (reader.Read())
                {
                    notification.ID = int.Parse(reader[0].ToString());
                    notification.EventTypeID = eventTypeId;
                    notification.NotificationType = notifyType;
                    notification.GroupName = reader[3].ToString();
                    notification.TemplateName = reader[4].ToString();
                    break;
                }
            }

            return notification;
        }
        /// <summary>
        /// The PostWebhookNotification method
        /// </summary>
        /// <param name="subscription">The subscription parameter</param>
        /// <param name="notificationTemplate">The notificationTemplate parameter</param>
        /// <returns>The boolean type object</returns>        
        public static bool PostWebhookNotification(Subscription subscription, NotificationTemplate notificationTemplate)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            string templateName = notificationTemplate.TemplateName.Replace('.', '_');
            string nrsEndPoint = "https://sl73cnsaapq001.visa.com:8443/notification/v1/notification-templates/ipn/json/webhook";
            var request = (HttpWebRequest)WebRequest.Create(nrsEndPoint);
            request.Method = "POST";
            string postData = "{     \"url\"  : \"https://sl73cnsaapq001.rrqa.visa.com:8443/MerchantEndPoint/Merchant\",     \"owner\": \"ANet\",     \"encryptedHashKey\" :\"{CBC}sus4W1+eVANo6fd1gLbhJUEB/kabXGnHxarYcAOrj50=\",    \"encryptionKey\" :\"PII05192015\",     \"data\" : {   \"requestId\": \"4387909360535000001540\",   \"merchantId\": \"ANet\",   \"gatewayName\": \"alipay\",   \"transactionReferenceNumber\": \"008899775512345\",   \"notificationDate\": \"2015-07-29 13:08:32\",   \"paymentStatus\": \"COMPLETEDA\",   \"transactionType\": \"" + templateName + "\",   \"processorMessage\": \"notify_type=trade_status_sync&notify_time=2015-07-29+13%3A08%3A32&out_trade_no=008899775512345&notify_reg_time=2015-07-29+11%3A06%3A32&total_fee=15&trade_status=TRADE_FINISHED&sign=YchKjjkr3c6kEdVqXfrZJAFRnG22kha4x9AA0hQrskZYha0cSDQT1heHDdPMC4WEeY6pJmy8hvJG%0D%0AnFUjEBw0hBfmFpRlccAcwVmvaJLXt8apKHVbRGXVhXRVzdG6074djCwAZE4arStscdmVsRXOVjJy%0D%0A73y3DmqkOdT9GgfBWpc3IUBkXQWsL%2BpfUp5I0iuI3P93OvLhnkzkO4MOIAL0y8R3D%2FcTXPXpXLja%0D%0AfVchDpgZrorUbrdlkPH2F6qlLW8KJ9TfMfciOWmAOm3kRTz%2FmTOv%2FVIE7v4W1uejWTpHdWYHoMD%2B%0D%0AC8Fx4rwlbI%2BWrrPiqD8pscXlBQ1mM5QJIc8UpQ%3D%3D&trade_no=2010012489527852&currency=USD&sign_type=RSA&notify_id=70fec0c2730b27528665af4517c27b95\",   \"merchantReferenceNumber\": \"TC66932-1\",   \"originalTransactionDate\": \"2015-08-05 16:08:56.0\",   \"transactionAmount\": \"100\",   \"transactionCurrencyCode\": \"USD\" } }";

            // request.
            // add cert
            request.ClientCertificates.Add(new X509Certificate("C:/Users/nbansal/Desktop/vcasclient.visa.com.p12", "password")); 
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/json";

            // Get the request stream.
            StreamWriter dataStream = new StreamWriter(request.GetRequestStream());

            // Write the data to the request stream.
            dataStream.Write(postData);
            dataStream.Flush();

            // Close the Stream object.
            dataStream.Close();
            HttpWebResponse response;
            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException)
            {
                throw;
            }

            var status = ((HttpWebResponse)response).StatusDescription;
            if (string.Compare(status, "Created") == 0)
            {
                return true;
            }

            return false;
        }
        /// <summary>
        /// The PostEmailNotification method posts the notification
        /// </summary>
        /// <param name="subscription">The subscription parameter</param>
        /// <param name="notificationTemplate">The notificationTemplate parameter</param>
        /// <returns>The boolean type object</returns>        
        public static bool PostEmailNotification(Subscription subscription, NotificationTemplate notificationTemplate)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            string templateName = notificationTemplate.TemplateName.Replace('.', '_');
            string nrsEndPoint = "https://sl73cnsaapq001.visa.com:8443/notification/v1/notification-templates/mpos/" + templateName + "/email";
            var request = (HttpWebRequest)WebRequest.Create(nrsEndPoint);
            request.Method = "POST";
            string postData = "{     \"owner\": \"ANet\",     \"toAddress\": \"" + subscription.NotificationEndpoint.Summary + "\",     \"fromAddress\": \"[email protected]\",     \"subject\": \"Email from Event Model POC\",  \"displayName\" : \"ANet EventModelPOC\",   \"data\": {    \"eventType\" : \" " + notificationTemplate.TemplateName + "\"     } } ";
            
            // add cert
            request.ClientCertificates.Add(new X509Certificate("C:/Users/nbansal/Desktop/vcasclient.visa.com.p12", "password"));
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/json";

            // Get the request stream.
            StreamWriter dataStream = new StreamWriter(request.GetRequestStream());

            // Write the data to the request stream.
            dataStream.Write(postData);
            dataStream.Flush();

            // Close the Stream object.
            dataStream.Close();
            HttpWebResponse response;
            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException)
            {
                throw;
            }
            
            var status = ((HttpWebResponse)response).StatusDescription;
            if (string.Compare(status, "Created") == 0)
            {
                return true;
            }

            return false;
        }
 /// <summary>
 /// The PostWebhookNotification method
 /// </summary>
 /// <param name="subscription">The subscription parameter</param>
 /// <param name="notificationTemplate">The notificationTemplate parameter</param>
 /// <returns>returns true or false respectively</returns>        
 public static bool PostWebhookNotification(Subscription subscription, NotificationTemplate notificationTemplate)
 {
     return NRS.NRS.PostWebhookNotification(subscription, notificationTemplate);
 }