diff options
Diffstat (limited to 'samples/OAuthResourceServer/Default.aspx.cs')
-rw-r--r-- | samples/OAuthResourceServer/Default.aspx.cs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/samples/OAuthResourceServer/Default.aspx.cs b/samples/OAuthResourceServer/Default.aspx.cs new file mode 100644 index 0000000..502e039 --- /dev/null +++ b/samples/OAuthResourceServer/Default.aspx.cs @@ -0,0 +1,43 @@ +namespace OAuthResourceServer { + using System; + using System.Configuration; + using System.IO; + + using 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.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 |