Welcome to the BlogAPI project! This project is a simple yet robust blog API built with .NET 8, Entity Framework Core, and ASP.NET Core Identity. The API allows users to register, login, create blog posts, comment on blog posts and other comments, and like blog posts and comments. This project demonstrates a clean architecture and best practices in building a RESTful API.
- User registration and authentication using ASP.NET Core Identity
- CRUD operations for blog posts
- Nested comments on blog posts and other comments
- Like functionality for blog posts and comments with unique constraints
- Role-based authorization for managing blog content
-
ASP.NET Core: ASP.NET Core is a cross-platform framework for building modern, cloud-based, and internet-connected applications.
-
Entity Framework: Entity Framework (EF) is an ORM for .NET that simplifies data access by allowing developers to work with database objects using .NET objects.
-
Identity Framework: ASP.NET Core Identity is a membership system that supports user authentication, authorization, and management.
-
MsSQL: Microsoft SQL Server (MsSQL) is a relational database management system that provides high performance, security, and data integrity.
-
Swagger: Swagger is a tool for designing, building, and documenting RESTful APIs with a user-friendly interface for testing endpoints.
BlogAPI-SoftITO/
├── Controllers/
├── Data/
├── Entities/
│ ├── Models/
│ ├── DTOs/
├── Migrations/
├── Properties/
- Controllers: Contains the API controllers for handling HTTP requests.
- DTOs: Data Transfer Objects for transferring data between client and server.
- Models: Entity models representing the database schema.
- Data: Database context and configuration for Entity Framework Core.
- .NET 8 SDK
- MsSQL Server (or any other compatible database)
- Visual Studio or VS Code
-
Clone the repository:
git clone https://github.com/denizciMert/BlogAPI.git
-
Set up the database connection string in appsettings.json:
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "ConnectionStrings": { "ApplicationDbContext": "YourConnectionString" } }
-
Build and run the project:
dotnet build
dotnet run
Method | Endpoint | Description |
---|---|---|
POST | /api/account/register | Register a new user |
POST | /api/account/login | Login a user |
POST | /api/account/logout | Logout the current user |
Method | Endpoint | Description |
---|---|---|
GET | /api/blogpost | Get all blog posts |
GET | /api/blogpost/{id} | Get a single blog post by ID |
POST | /api/blogpost | Create a new blog post (authorized users only) |
PUT | /api/blogpost/{id} | Update a blog post (authorized users only) |
DELETE | /api/blogpost/{id} | Soft delete a blog post (authorized users only) |
Method | Endpoint | Description |
---|---|---|
GET | /api/comments | Get all comments |
GET | /api/comments/{id} | Get a single comment by ID |
POST | /api/comments | Create a new comment (authorized users only) |
PUT | /api/comments/{id} | Update a comment (authorized users only) |
DELETE | /api/comments/{id} | Soft delete a comment (authorized users only) |
Method | Endpoint | Description |
---|---|---|
POST | /api/likes | Like a blog post or comment (authorized users only) |
DELETE | /api/likes | Unlike a blog post or comment (authorized users only) |
- This project was developed as part of the backend program at Softito Yazılım - Bilişim Akademisi.
- Special thanks to the instructors and peers who provided valuable feedback and support throughout the development process.