Git Product home page Git Product logo

msa-phase-1---backend-api's Introduction

Microsoft Student Accelerator Phase 1 - Backend API

Basic Overview

Created as a module to complete Microsoft Student Accelerator Phase 1 - Backend Pathway.

To access my Swagger UI with my solution please click here.

Tasks:

  • Database
    • Create an additional Address with attributes: StudentId, Street Number, Street, Suburb, City, Postcode and Country and assign appropriate datatype for each of attributes.
    • Show SQL Database through the Query Editor (screenshots) for both tables with rows of example instances.
  • API
    • Create basic CRUD requests for the Student and Address table.
    • Create an API method that adds new address for a student using his/her StudentId.
    • Create an API method that changes the address of a student using his/her Student Id.
    • Screenshot of Swagger UI showing all API Endpoints.

Database

An Address table has the following JSON object model created with code-first approach.

StudentId has been given as a foreign key which points to the Student table.

[
  {
    "addressID": 0,
    "streetNumber": 0,
    "street": "string",
    "suburb": "string",
    "city": "string",
    "country": "string",
    "postcode": 0,
    "studentId": 0,
    "student": {
      "studentId": 0,
      "firstName": "string",
      "middleName": "string",
      "lastName": "string",
      "emailAddress": "string",
      "phoneNumber": 0
    }
  }
]

Below are images showing the table(s) on Query editor with example instances. You can see that the studentId is associated with the following photo's student entry in studentId number 62.

address_azure

student_azure

API

Create basic CRUD requests for Student and Address Table

These have been created using the in-built controller as demonstrated in the tutorials. Please see following images to see CRUD requests being demonstrated.

Create an API method that adds new address for a student using his/her StudentID

My back-end does a sanity check to see if the student is actually in the table, otherwise it throws a NotFound(). Student is then able to provide details ( StudentId, Street Number, Street, Suburb, City, Postcode and Country ) in the request. The back-end will then auto-generate a new PK (addressID) and this will automatically be associated with the student using the FK (StudentId).

Below shows the user adding to studentId #62 the address. I have not given an addressID as this is allocated automatically.

addressAPI1

Below is an image of the response from the Backend showing the address with the new PK addressID and the associated studentId and student.

addressAPI2

Create an API method that changes the address of a student using his/her StudentID

I assumed here that it meant that given a Student's ID they are able to update their address (singular) assuming that they have the addressID of the address he/she want to update.

I used the endpoint /api/StudentAddress/{id} to differ from updating a normal address using /api/Address/{id}.

Below shows the user updating their address using their studentId as the input. addressID needs to be entered as there can be multiple addressses associated with one student.

studentaddressAPI1

Below shows the response from the Backend showing 204 meaning no content to show.

studentaddressAPI2

Below is the GET request on all addresses which shows the address has been updated successfully.

studentaddressAPI3

Images showing the API Endpoints hosted on Azure using the Swagger UI.

Below are all the API endpoints available on both Student and Address table showing all basic CRUD methods and the additional:

  1. POST /api/Addresses/{id}
  2. PUT /api/StudentAddress/{id}.

Swagger_UI

msa-phase-1---backend-api's People

Contributors

road2paradise avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.