This project is a web API built using ASP.NET Core and follows the principles of Onion Architecture for better separation of concerns and maintainability.
- Contains the domain model of the application.
- Directories:
Constants
: Definitions of constant values used within the app.Contracts
: Interfaces or abstract classes defining the contracts thatRepositories
inCards.Persistence
layer implement. Also acts as intermediary betweenCards.Domain
andCards.Services
layer.Entities
: Domain entities representing core business objects.ErrorModel
: Models representing error information.Exceptions
: Custom exception types.Shared
: Shared utility classes.
- Contains business logic and application services.
- Directories:
Abstraction
: Interfaces or abstract classes defining service contracts thatServices
implement. Also acts as intermediary betweenCards.Services
andCards.Presentation
layer.Dtos
: Data transfer objects used for transferring data betweenCards.Services
andCards.Presentation
layer.Services
: Implementations ofAbstraction
application services. Containing the core business logic.MappingProfiles.cs
: AutoMapper mapping profiles for mapping betweenCards.Domain
Entities
andCards.Services
DTOs
.
- Concerned with presentation logic, such as handling incoming requests and returning responses.
- Directories:
ActionFilters
: Custom action filters for checking the model state of the incoming request.Controllers
: Responsible for handling incoming HTTP requests and invoking the appropriate services.
- Responsible for data persistence concerns.
- Directories:
Configurations
: Entity configurations for mappingCards.Domain
Entities
to the database schema.Extensions
: Extension methods relevant to persistence operations.Migrations
: Database migration scripts for managing schema changes.Repositories
: Implementations ofContracts
interfaces defined in theCards.Domain
layer.DbContext
: Database context class for interacting with the underlying database.
- The outermost layer of the application, serving as the entry point for the web API.
- Directories:
Extensions
: Extension methods for configuring services in the application.GlobalExceptionHandler.cs
: Global exception handling middleware for handling exceptions in the application.Program.cs
: The entry point class for configuring and running the application.
- Frontend: HTML, CSS, Bootstrap 5, JavaScript
- Backend: ASP.NET Core Web API with C#
- Database: PostgreSQL
- Data Access: Entity Framework Core
- Platform: .NET 8.0
- API Tests: Insomnia
clone and open the solution file in Visual Studio
Set a database connection string,DefaultConnection
, in the Cards.Web project's appsettings.json or use Secrets
Example config setting in appsettings.json for a database called Cards
:
"ConnectionStrings": {
"DefaultConnection": "Host=localhost; Database=Cards; Username=postgres; Password=yourpassword"
}
"yourpassword" - password to your database
Method 1
- Open Package Manager Console in visual studio.
- Select the
Cards.Persistence
project from the dropdown as shown below. - Run command "update-database" to create the database and seed the data.
Method 2
- Use pgAdmin to create an empty database named Cards.
- Import the Cards.sql file from the AppData directory of this project.
- Set the Startup Item in your IDE to https and start the server.
-- Open Insomnia (or another tool) and import the Cards.json file from the AppData
directory of this project.
HTTP Method | POST |
End-point | {{baseUrl}}/api/authentication/ |
Field | Position | Data Type | Required | Description |
---|---|---|---|---|
Content-Type = Application/json | Header | Yes | - | |
body | string | Yes | User email. | |
password | body | string | Yes | User password. |
{
"email": "[email protected]",
"password": "testuserP@ssorwd1"
}
HTTP Method | POST |
End-point | {{baseUrl}}/api/authentication/login |
Field | Position | Data Type | Required | Description |
---|---|---|---|---|
Content-Type = Application/json | Header | Yes | ||
Body | String | Yes | User email. | |
password | Body | String | Yes | User password. |
{
"email": "[email protected]",
"password": "kevP@ssword1"
}
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9lbWFpbGFkZHJlc3MiOiJrZXZAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiTWVtYmVyIiwiaXNzIjoiQ2FyZHNBUEkiLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdDo3MjY1In0.o4WBWXaJdS9xhhRmSwaY0wwuMo40J1A-oSi4WjZZnZE"
}
HTTP Method | POST |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/ |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
name | Body | string | Yes | Card name. |
description | Body | string | No | Card description. |
color | Body | string | No | Card color. |
{{baseUrl}}/api/appUsers/kev5f943-112f-4d49-888d-c671e210b8b8/cards/
{
"Name": "Client Meeting",
"description": "Discuss project milestone.",
"color": "#00FF00"
}
{
"cardId": "64491916-b423-408c-a29a-6184c24cdf0d",
"name": "Client Meeting",
"description": "Discuss project milestone.",
"dateOfCreation": "2024-03-22T09:10:28.626608Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00FF00"
}
HTTP Method | PUT |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/{cardId} |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
cardId | Query String | String | Yes | Card ID. |
name | Body | String | Yes | Card name. |
status | Body | String | Yes | Card status. |
description | Body | String | No | Card description. |
color | Body | String | No | Card color. |
{{baseUrl}}/api/appUsers/kev5f943-112f-4d49-888d-c671e210b8b8/cards/updateDatabase-f8a1-49e2-b7ab-2f5c6d73c93d
{
"name": "Update Database",
"status": "Done",
"description": "Discuss project milestones with the client.",
"color": "#00FF00"
}
HTTP Method | DELETE |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/{cardId} |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
cardId | Query String | String | Yes | Card ID. |
{{baseUrl}}/api/appUsers/kev5f943-112f-4d49-888d-c671e210b8b8/cards/clientMeeting-2f9e-4681-a499-4a2d1b2e36e4
HTTP Method | GET |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/{cardId} |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
cardId | Query String | String | Yes | Card ID. |
{{baseUrl}}/api/appUsers/kev5f943-112f-4d49-888d-c671e210b8b8/cards/updateDatabase-f8a1-49e2-b7ab-2f5c6d73c93d
{
"cardId": "updateDatabase-f8a1-49e2-b7ab-2f5c6d73c93d",
"name": "Update Database",
"description": "Perform necessary updates on the database.",
"dateOfCreation": "2024-02-05T15:20:00Z",
"status": "In Progress",
"createdByAppUser": "[email protected]",
"color": "#32CD32"
}
User Role | ||
---|---|---|
HTTP Method | GET | - |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/all | Admin |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/forUser | Member |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
{{baseUrl}}/api/appUsers/admin46d-9e9f-44d3-8425-263ba67509aa/cards/all
[
{
"cardId": "clientMeeting-7c8a-4a7d-9533-56a21b5c92e1",
"name": "Client Meeting",
"description": "Discuss project milestones and deliverables with the client.",
"dateOfCreation": "2024-02-25T14:30:00Z",
"status": "In Progress",
"createdByAppUser": "[email protected]",
"color": "#4682B4"
},
{
"cardId": "clientMeeting-6c72-45fe-a7bf-4cd6d1d90c91",
"name": "Client Meeting",
"description": "Review project scope and timeline with the client.",
"dateOfCreation": "2024-03-05T11:00:00Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#8A2BE2"
},
{
"cardId": "a04ce30d-6f36-4fc2-a3b0-e13b9b02b0b8",
"name": "Security Audit",
"description": "",
"dateOfCreation": "2024-04-10T18:41:05.093498Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#0400ff"
},
{
"cardId": "4d5a8694-bd75-4199-8531-81f10e90ac1d",
"name": "Software Upgrade",
"description": "",
"dateOfCreation": "2024-04-10T05:40:21.870919Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00ff00"
},
{
"cardId": "239e7b6b-e0f8-4c9d-a644-74b92e9ad32a",
"name": "Software Upgrade",
"description": "",
"dateOfCreation": "2024-04-10T05:38:49.084651Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00ff00"
},
{
"cardId": "semIstalltion-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "systemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "sysemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "semIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "d10caae9-c6c9-47d4-9b19-bec30b4a94f5",
"name": "System Intallation",
"description": null,
"dateOfCreation": "2024-03-22T16:20:28.600347Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": null
}
]
User Role | ||
---|---|---|
HTTP Method | GET | - |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/all | Admin |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/forUser | Member |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
name | Query String | - | No | Card name |
color | Query String | - | No | Card color |
status | Query String | - | No | Card status |
dateOfCreation | Query String | - | No | Card Date of Creation |
{{baseUrl}}/api/appUsers/admin46d-9e9f-44d3-8425-263ba67509aa/cards/all?name=Client%20Meeting&color=%238A2BE2&status=%20todo&dateOfCreation=2024-03-05
[
{
"cardId": "clientMeeting-6c72-45fe-a7bf-4cd6d1d90c91",
"name": "Client Meeting",
"description": "Review project scope and timeline with the client.",
"dateOfCreation": "2024-03-05T11:00:00Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#8A2BE2"
}
]
User Role | ||
---|---|---|
HTTP Method | GET | - |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/all | Admin |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/forUser | Member |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
orderBy | Query String | - | No | Order query string parameters |
{{baseUrl}}/api/appUsers/admin46d-9e9f-44d3-8425-263ba67509aa/cards/all?orderBy=name,color,status%20desc,dateOfCreation%20desc
[
{
"cardId": "clientMeeting-7c8a-4a7d-9533-56a21b5c92e1",
"name": "Client Meeting",
"description": "Discuss project milestones and deliverables with the client.",
"dateOfCreation": "2024-02-25T14:30:00Z",
"status": "In Progress",
"createdByAppUser": "[email protected]",
"color": "#4682B4"
},
{
"cardId": "clientMeeting-6c72-45fe-a7bf-4cd6d1d90c91",
"name": "Client Meeting",
"description": "Review project scope and timeline with the client.",
"dateOfCreation": "2024-03-05T11:00:00Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#8A2BE2"
},
{
"cardId": "a04ce30d-6f36-4fc2-a3b0-e13b9b02b0b8",
"name": "Security Audit",
"description": "",
"dateOfCreation": "2024-04-10T18:41:05.093498Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#0400ff"
},
{
"cardId": "4d5a8694-bd75-4199-8531-81f10e90ac1d",
"name": "Software Upgrade",
"description": "",
"dateOfCreation": "2024-04-10T05:40:21.870919Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00ff00"
},
{
"cardId": "239e7b6b-e0f8-4c9d-a644-74b92e9ad32a",
"name": "Software Upgrade",
"description": "",
"dateOfCreation": "2024-04-10T05:38:49.084651Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00ff00"
},
{
"cardId": "semIstalltion-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "sysemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "semIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "systemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "d10caae9-c6c9-47d4-9b19-bec30b4a94f5",
"name": "System Intallation",
"description": null,
"dateOfCreation": "2024-03-22T16:20:28.600347Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": null
}
]
User Role | ||
---|---|---|
HTTP Method | GET | - |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/all | Admin |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/forUser | Member |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
pageNumber | Query String | - | No | Which page of results to retrive. |
pageSize | Query String | - | No | Number of results to include per page. |
{{baseUrl}}api/appUsers/admin46d-9e9f-44d3-8425-263ba67509aa/cards/all?pageNumber=2&pageSize=3
[
{
"cardId": "239e7b6b-e0f8-4c9d-a644-74b92e9ad32a",
"name": "Software Upgrade",
"description": "",
"dateOfCreation": "2024-04-10T05:38:49.084651Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00ff00"
},
{
"cardId": "4d5a8694-bd75-4199-8531-81f10e90ac1d",
"name": "Software Upgrade",
"description": "",
"dateOfCreation": "2024-04-10T05:40:21.870919Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#00ff00"
},
{
"cardId": "sysemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
}
]
User Role | ||
---|---|---|
HTTP Method | GET | - |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/all | Admin |
End-point | {{baseUrl}}/api/appUsers/{appUserId}/cards/forUser | Member |
Position | Data Type | Required | Description | |
---|---|---|---|---|
Content-Type = Application/json | Header | - | Yes | - |
authorization | Bearer Token | - | Yes | Token used to check authorization of user to use the API. |
appUserId | Query String | - | Yes | App User ID |
pageNumber | Query String | - | No | Which page of results to retrive. |
pageSize | Query String | - | No | Number of results to include per page. |
name | Query String | - | No | Card name |
color | Query String | - | No | Card color |
status | Query String | - | No | Card status |
dateOfCreation | Query String | - | No | Card Date of Creation |
orderBy | Query String | - | No | Order query string parameters |
{{baseUrl}}/api/appUsers/admin46d-9e9f-44d3-8425-263ba67509aa/cards/all?pageNumber=1&pageSize=2&name=System%20Installation&color=%23FF7F50&status=%20todo&dateOfCreation=2024-01-15&orderBy=name,color,status%20desc,dateOfCreation%20desc
[
{
"cardId": "sysemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
},
{
"cardId": "systemIstallation-8fae-7488fc2c1b95",
"name": "System Installation",
"description": "Installation of system to the new client.",
"dateOfCreation": "2024-01-15T17:37:19Z",
"status": "ToDo",
"createdByAppUser": "[email protected]",
"color": "#FF7F50"
}
]
{{baseUrl}}/Auth/Login
Admin Login Credentials | |
---|---|
[email protected] | |
password | adminP@ssword1 |
Member Login Credentials | |
---|---|
[email protected] | |
password | kevP@ssword1 |
{{baseUrl}}/swagger/index.html