Skip to content

Projects CRUD

Krzysztof Dubiło edited this page Mar 17, 2022 · 3 revisions

Overview

This application allows you to create, read, modify and delete previously created projects.

Each of the available actions is described here.

Crate new project

If you want to add a new project, you have to send a request with HTTP PUT method. The endpoint of this action is "api/project".

In the request body you have to insert a body in JSON format, like shown below.

There are three string field (Alias, Name and Description) witch are required. The 'IsActive' field is set true by default.

It means that by default active project is beeing created. Nevertheless it is possible to create inactive project by seting field 'isActive' value to false.

{
  "alias": "string",
  "name": "string",
  "description": "string",
  "isActive": true
}

If all goes fine, you will receive the following response (view in Swagger):

image

There is response body in which you have, among other things: response code (201 - Created / 400 - Bad Request) and Data (Id of created project).

There is also a header in which you have a URI (location) to crated project.

Read all projects

If you want to get a list of a projects, you have to send a request with HTTP GET method. The endpoint of this action is "api/project". It is possible to filter a results. You can specify an expression that must be contained in the name, alias or description (any of the following may contain the specified phrase). If you don't specify any expresion, then you will receive all projects.

image

Read single project

If you want to get a single project, you have to send a request with HTTP GET method. The endpoint of this action is "api/project/{id}", where {id} is a identifier of a searched project.

image

Update project - it's all properties

If you want to update a project, you have to send a request with HTTP PUT method. The endpoint of this action is "api/project/{id}". In the request body you have to insert a body in JSON format, like shown below. It is required to enter all properties.

{
   "Name": "Name of project",
   "Alias": "Project's alias",
   "Description": "Project's description",
   "isActive": true
}

Update only selected properties of project

It is possible to update only selected properties of project. In this case you have to send a request with HTTP PATCH methodto the "api/project/{id}" endpoint. In the request body you have to insert a body in JSON format, like shown below. If you want to not update some property, you can enter a "null" (like in "alias") or do not enter anything (like in "name"). If a field is nullable and you want to insert a "null" value into in, you can do it like shown in the example below for "description" property. If you want to specify a new not null value, you can do it like for "isActive" property in the example.

{
  "alias": null,
  "description": {
    "data": null
  },
  "isActive": {
    "data": false
  }
}

Delete project

If you want to delete a project, you have to send a request with HTTP DELETE method. The endpoint of this action is "api/project/{id}". The specified project actually will not be deleted, but it's flag "isActive" will be changed to "false".