Show / Hide Table of Contents

Class ItemApiController

Defines the Web API controller that handles HTTP methods GET, PUT, POST, and DELETE.

Inheritance
System.Object
Microsoft.AspNetCore.Mvc.ControllerBase
ItemApiController
Namespace: Scrapbook101core.Controllers
Assembly: Scrapbook101core.dll
Syntax
[Route("api/[controller]")]
[ApiController]
public class ItemApiController : ControllerBase

Methods

| Improve this Doc View Source

CreateAsync(Item)

Creates a new Scrapbook101core item.

Declaration
[HttpPost(Name = "Create")]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
public async Task<ActionResult<string>> CreateAsync([FromBody] Item value)
Parameters
Type Name Description
Item value

JSON representing the item.

Returns
Type Description
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<System.String>>
Remarks

Specify the HTTP POST method, the URI "baseURI/api/ItemApi", and the item details in the request body.

Required fields are determined by the Required attribute used in the Item class definition. Not specifying a required item results in an 400 response. At least the Title, Type, and Category of the item must be specified. Do not specify the item ID as it will be auto-assigned when saved.

| Improve this Doc View Source

DeleteAsync(String)

Deletes the item matching the specified GUID.

Declaration
[HttpDelete("{id}", Name = "Delete")]
[ProducesResponseType(202)]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
public async void DeleteAsync(string id)
Parameters
Type Name Description
System.String id

The GUID of the item to delete.

Remarks

Specify the HTTP method DELETE and the URI "baseURI/api/ItemApi/GUID".

| Improve this Doc View Source

DetailsAsync(String)

Return the item matching the specified GUID.

Declaration
[HttpGet("{id}", Name = "Details")]
public async Task<ActionResult<Item>> DetailsAsync(string id)
Parameters
Type Name Description
System.String id

The GUID of the item to return.

Returns
Type Description
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<Item>>

JSON representing the specified item.

Remarks

Specify the HTTP GET method and the URI "baseURI/api/ItemApi/GUID".

| Improve this Doc View Source

GetAsync(String)

Returns Scrapbook101 items whose title or body matches filter. If filter is omitted, all items are returned.

Declaration
[HttpGet]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<ActionResult<IEnumerable<Item>>> GetAsync([FromQuery] string filter)
Parameters
Type Name Description
System.String filter

Optional string to find in titles and descriptions.

Returns
Type Description
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<System.Collections.Generic.IEnumerable<Item>>>

JSON representing of all matching items.

Remarks

Specify the HTTP GET method and the URI "baseURI/api/ItemApi?filter=filter".

| Improve this Doc View Source

UpdateAsync(String, Item)

Updates an existing Scrapbook101core item.

Declaration
[HttpPut("{id}", Name = "Update")]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
public async Task<ActionResult<string>> UpdateAsync(string id, [FromBody] Item value)
Parameters
Type Name Description
System.String id

The GUID of the item to update.

Item value

JSON representing the item to update.

Returns
Type Description
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<System.String>>
Remarks

Specify the HTTP PUT method, the URI "baseURI/api/ItemApi/GUID", and the items details in the request body.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX for Scrapbook101Core on