Use SPWeb.WebTemplate to get the name of the template. 

using (SPSite thisSite = new SPSite(properties.FullUrl))
        {
            SPWeb thisWeb = thisSite.OpenWeb();

            string MyTempleName = thisWeb.WebTemplate ;

        }


Get Custom Web template name programmatically , Sharepoint 2013
What is the significance of the time it takes to say Shalom Alecha Rebbi (U'mori)?
