Skip to content

Latest commit

 

History

History
218 lines (164 loc) · 4.41 KB

README.md

File metadata and controls

218 lines (164 loc) · 4.41 KB

This is the training code of the CRUD REST API from scratch using .NET 6 tutorial


Overview

In the tutorial, I build a CRUD REST API from scratch using .NET 6. As expect, the backend system supports Creating, Reading, Updating and Deleting breakfasts.

Service Architecture

drawing

Technologies

drawing

Architecture

drawing

Usage

Simply git clone https://github.com/MauricioSuporte/BuberBreakfast.git and dotnet run --project BuberBreakfast.

API Definition

Create Breakfast

Create Breakfast Request

POST /breakfasts
{
    "name": "Vegan Sunshine",
    "description": "Vegan everything! Join us for a healthy breakfast..",
    "startDateTime": "2022-04-08T08:00:00",
    "endDateTime": "2022-04-08T11:00:00",
    "savory": [
        "Oatmeal",
        "Avocado Toast",
        "Omelette",
        "Salad"
    ],
    "Sweet": [
        "Cookie"
    ]
}

Create Breakfast Response

201 Created
Location: {{host}}/Breakfasts/{{id}}
{
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "Vegan Sunshine",
    "description": "Vegan everything! Join us for a healthy breakfast..",
    "startDateTime": "2022-04-08T08:00:00",
    "endDateTime": "2022-04-08T11:00:00",
    "lastModifiedDateTime": "2022-04-06T12:00:00",
    "savory": [
        "Oatmeal",
        "Avocado Toast",
        "Omelette",
        "Salad"
    ],
    "Sweet": [
        "Cookie"
    ]
}

Get Breakfast

Get Breakfast Request

GET /breakfasts/{{id}}

Get Breakfast Response

200 Ok
{
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "Vegan Sunshine",
    "description": "Vegan everything! Join us for a healthy breakfast..",
    "startDateTime": "2022-04-08T08:00:00",
    "endDateTime": "2022-04-08T11:00:00",
    "lastModifiedDateTime": "2022-04-06T12:00:00",
    "savory": [
        "Oatmeal",
        "Avocado Toast",
        "Omelette",
        "Salad"
    ],
    "Sweet": [
        "Cookie"
    ]
}

Update Breakfast

Update Breakfast Request

PUT /breakfasts/{{id}}
{
    "name": "Vegan Sunshine",
    "description": "Vegan everything! Join us for a healthy breakfast..",
    "startDateTime": "2022-04-08T08:00:00",
    "endDateTime": "2022-04-08T11:00:00",
    "savory": [
        "Oatmeal",
        "Avocado Toast",
        "Omelette",
        "Salad"
    ],
    "Sweet": [
        "Cookie"
    ]
}

Update Breakfast Response

204 No Content

or

201 Created
Location: {{host}}/Breakfasts/{{id}}

Delete Breakfast

Delete Breakfast Request

DELETE /breakfasts/{{id}}

Delete Breakfast Response

204 No Content

Credits

  • ErrorOr - A simple, fluent discriminated union of an error or a result.

VSCode Extensions

  • VSCode Rest Client - REST Client allows you to send HTTP request and view the response in Visual Studio Code directly.

  • VSCode Markdown Preview Enhanced - Markdown Preview Enhanced is an extension that provides you with many useful functionalities for previewing markdown files.