summaryrefslogtreecommitdiffstats
path: root/src/OAuth/OAuthServiceProvider/Default.aspx.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/OAuth/OAuthServiceProvider/Default.aspx.cs')
-rw-r--r--src/OAuth/OAuthServiceProvider/Default.aspx.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/OAuth/OAuthServiceProvider/Default.aspx.cs b/src/OAuth/OAuthServiceProvider/Default.aspx.cs
new file mode 100644
index 0000000..653046a
--- /dev/null
+++ b/src/OAuth/OAuthServiceProvider/Default.aspx.cs
@@ -0,0 +1,49 @@
+namespace OAuthServiceProvider {
+ using System;
+ using System.Collections.Generic;
+ using System.Configuration;
+ using System.IO;
+ using System.Linq;
+ using System.Web;
+ using OAuthServiceProvider.Code;
+
+ public partial class _Default : System.Web.UI.Page {
+ protected void createDatabaseButton_Click(object sender, EventArgs e) {
+ string databasePath = Path.Combine(Server.MapPath(Request.ApplicationPath), "App_Data");
+ if (!Directory.Exists(databasePath)) {
+ Directory.CreateDirectory(databasePath);
+ }
+ string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.Replace("|DataDirectory|", databasePath);
+ var dc = new DataClassesDataContext(connectionString);
+ if (dc.DatabaseExists()) {
+ dc.DeleteDatabase();
+ }
+ try {
+ dc.CreateDatabase();
+
+ // Fill with sample data.
+ dc.OAuthConsumers.InsertOnSubmit(new OAuthConsumer {
+ ConsumerKey = "sampleconsumer",
+ ConsumerSecret = "samplesecret",
+ });
+ dc.Users.InsertOnSubmit(new User {
+ OpenIDFriendlyIdentifier = "=arnott",
+ OpenIDClaimedIdentifier = "=!9B72.7DD1.50A9.5CCD",
+ Age = 27,
+ FullName = "Andrew Arnott",
+ FavoriteSites = new System.Data.Linq.EntitySet<FavoriteSite> {
+ new FavoriteSite { SiteUrl = "http://www.microsoft.com" },
+ new FavoriteSite { SiteUrl = "http://www.google.com" },
+ },
+ });
+
+ dc.SubmitChanges();
+ this.databaseStatus.Visible = true;
+ } catch (System.Data.SqlClient.SqlException ex) {
+ foreach (System.Data.SqlClient.SqlError error in ex.Errors) {
+ Response.Write(error.Message);
+ }
+ }
+ }
+ }
+} \ No newline at end of file