rowidanagah / To_Do_HandsOnAPIS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

To_Do_HandsOnAPIS

Overview

We are going to create the following API:

URL Endpoint #Description #Request body #Response body
GET /api/todoitems Get all to-do items None Array of to-do items
GET /api/todoitems/{id} Get all to-do item byid None To-do items
POST /api/todoitems Add a new item To-do item To-do items
!PUT /api/todoitems/{id} Edit an existing item To-do item None
DELETE /api/todoitems/{id} Delet a to-do items None None

Model SnapShot

namespace To_Do_HandsOnAPIS.Models
{
    // The model for this app is a single TodoItem class.
    public class ToDoItem
    {
        public long Id { get; set; }
        public string? Name { get; set; } // allow null val
        public bool IsComplete { get; set; }
    }
}

Scaffolding in controller

Steps to follow
  • Right-click the Controllers folder.

  • Select Add > New Scaffolded Item.

  • Select API Controller with actions, using Entity Framework, and then select Add.

  • In the Add API Controller with actions, using Entity Framework dialog:

    • Select TodoItem (TodoApi.Models) in the Model class.
    • Select TodoContext (TodoApi.Models) in the Data context class.
    • Select Add.

About


Languages

Language:C# 92.2%Language:HTML 5.5%Language:CSS 2.0%Language:JavaScript 0.3%