Skip to content

GeorgeIniatis/ASP.NET_Core_MVC_Playground

Repository files navigation

ASP.NET Core MVC Playground

This is just a playground site where multiple ASP.NET Core, Javascript and Bootstrap elements have been implemented as a way to get familiar with them.

Azure Deployed Site

  • Link (Try refreshing if you get an error)

  • The deployment utilised two separate SQL databases and a Key Vault to securely store and fetch any API keys and secrets needed by the web app.

  • Azure DevOps used for CI/CD.

Running Site Locally

Assuming you are using Visual Studio 2019 or Visual Studio 2022

  1. Inside secrets.json which can be accessed by right-clicking on your project and clicking Manage User Secrets input the following information following the exact format and replacing the dictionary values with your own API Keys. You do not have to enter every single one but the ConnectionStrings are a must.
// File Format
{
  "AppSettings: {
    "Url": "https://localhost:PORT/"
  },
  "ConnectionStrings": {
    "IdentityDb": "IdentityDb",
    "DataDb": "DataDb"
  },
  "Authentication": {
    "Google": {
      "ClientId": "ClientId",
      "ClientSecret": "ClientSecret"
    },
    "Facebook": {
      "AppID": "AppID",
      "AppSecret": "AppSecret"
    },
    "Twitter": {
      "ApiKey": "ApiKey",
      "SecretKey": "SecretKey",
    },
    "Microsoft": {
      "ClientID": "ClientID",
      "ClientSecret": "ClientSecret"
    }
  },
  "EmailService": {
    "Mailjet": {
      "ApiKey": "ApiKey",
      "SecretKey": "SecretKey"
    },
    "Sendgrid": {
      "ApiKey": "ApiKey"
    }
  },
  "SmsService": {
    "Twilio": {
      "AccountSID": "AccountSID",
      "AuthToken": "AuthToken",
      "PhoneNumber": "+PhoneNumber"
    }
  },
  "AdminAccount": {
    "FirstName": "Admin",
    "LastName": "McAdmin",
    "Email": "[email protected]",
    "Password": "adminTestpa%$ssword3648"
  },
  "DbResourceConfiguration": {
    "GoogleApiKey": "GoogleApiKey",
  },
  "Stripe": {
    "PublishableKey": "PublishableKey",
    "SecretKey": "SecretKey",
    "EndpointSecretKey": "EndpointSecretKey"
  }
}
  1. Data Migrations
add-migration initialCreate -context DataDbContext -o "Data/Migrations"
update-database -context DataDbContext
  1. Identity Migrations
add-migration initialCreate -context IdentityDbContext -o "Areas/Identity/Data/Migrations"
update-database -context IdentityDbContext
  1. Run XUnit Tests

  2. Access Site

  • You can register a normal user and sign in but you will only have access to a limited number of pages or

  • Login with admin user automatically created to access all the available pages

Username: [email protected]
Password: adminTestpa%$ssword3648
  1. Buy Something
  • Using an account go to the Items page and add stuff to the basket. Then go to the Checkout page and enter one of the testing 'credit cards' which you can find here.
  1. Test Stripe Webhook Integration
  • Download Stripe CLI and run the following commands
stripe login
stripe listen --forward-to https://localhost:44395/webhook
  1. Disclaimers
  • Only the Items Page has been setup fully for Localisation and Globalization, but without the database table changing the locale will have almost no effect except showing the variable names used

  • The SMS service will only work with number you have chosen during the set up of Sendgrid.

  • The Email service may or may not work. What I would suggest is using a temp email.