Skip to content

added feature country_region#96

Merged
mihaduldev merged 5 commits into
Devfrom
country_region
Dec 9, 2025
Merged

added feature country_region#96
mihaduldev merged 5 commits into
Devfrom
country_region

Conversation

@MehediHasan19013
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Region and District entities to the application, establishing a hierarchical geographic structure (Country → Region → District) with full CRUD operations for both entities. The implementation follows the existing clean architecture pattern with domain entities, application layer commands/queries, and API endpoints.

Key Changes:

  • Added Region and District domain entities with relationships to Country
  • Implemented CRUD endpoints for Regions and Districts with proper authorization
  • Added database migrations and entity configurations for both entities

Reviewed changes

Copilot reviewed 52 out of 54 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Web.Api/appsettings.json Updated database connection string with new password
src/Web.Api/Endpoints/Tags.cs Added Regions and Districts API tags
src/Web.Api/Endpoints/Regions/* Created CRUD endpoints for Region management
src/Web.Api/Endpoints/Districts/* Created CRUD endpoints for District management
src/Domain/Regions/* Added Region entity and error definitions
src/Domain/Districts/* Added District entity and error definitions
src/Application/Regions/* Implemented Region CRUD commands, queries, and validators
src/Application/Districts/* Implemented District CRUD commands, queries, and validators
src/Infrastructure/Regions/RegionConfiguration.cs EF Core configuration for Region entity
src/Infrastructure/Districts/DistrictConfiguration.cs EF Core configuration for District entity
src/Infrastructure/Database/ApplicationDbContext.cs Added DbSet properties for Regions and Districts
src/Infrastructure/Migrations/* Database migrations for new entities
src/Application/Abstractions/Data/IApplicationDbContext.cs Added Regions and Districts to context interface
Files not reviewed (2)
  • src/Infrastructure/Migrations/20251208155424_InitialCreate.Designer.cs: Language not supported
  • src/Infrastructure/Migrations/20251209073507_AddDistrictEntity.Designer.cs: Language not supported

Comment thread src/Domain/Districts/District.cs Outdated
Comment on lines +2 to +3
using System.Collections.Generic;
using System.Text;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports should be removed. The System.Collections.Generic and System.Text namespaces are not used in this file.

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +40
.WithTags(Tags.Districts)
.RequireAuthorization();
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing API documentation. Add .WithSummary() and .WithDescription() calls to document this endpoint, consistent with other endpoints in the codebase.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,43 @@
using System;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import System should be removed as it's not needed when other System namespace imports are present.

Copilot uses AI. Check for mistakes.
Comment thread src/Web.Api/appsettings.json Outdated
"AllowedHosts": "*",
"ConnectionStrings": {
"Database": "Host=localhost;Port=5432;Database=clean-architecture;Username=postgres;Password=1234;Include Error Detail=true"
"Database": "Host=localhost;Port=5432;Database=clean-architecture;Username=postgres;Password=mehedi13;Include Error Detail=true"
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database credentials (password: "mehedi13") should not be committed to version control. Store sensitive configuration values in environment variables or user secrets instead.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread src/Domain/Districts/DistrictErrors.cs Outdated
Comment on lines +10 to +14
public static Error NotFound(Guid id) =>
new Error(
"Region.NotFound",
$"Region with Id '{id}' was not found.",
ErrorType.NotFound);
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error code and message refer to "Region" instead of "District". This should be:

new Error(
    "District.NotFound",
    $"District with Id '{id}' was not found.",
    ErrorType.NotFound);

Copilot uses AI. Check for mistakes.
Comment thread src/Domain/Districts/DistrictErrors.cs Outdated
Comment on lines +2 to +3
using System.Collections.Generic;
using System.Text;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports should be removed. The System.Collections.Generic and System.Text namespaces are not used in this file.

Copilot uses AI. Check for mistakes.
}

// Update fields
district.RegionId = command.RegionId;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CountryId parameter is accepted but never used in the update handler. Consider removing it from the command and request, or ensure it's properly validated/used if it's meant to update the district's country assignment.

Suggested change
district.RegionId = command.RegionId;
district.RegionId = command.RegionId;
district.CountryId = command.CountryId;

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,35 @@
using Application.Abstractions.Authentication;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import Application.Abstractions.Authentication should be removed as it's not used in this file.

Suggested change
using Application.Abstractions.Authentication;

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
.WithTags(Tags.Regions)
.RequireAuthorization();
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing API documentation. Add .WithSummary() and .WithDescription() calls to document this endpoint, consistent with other endpoints in the codebase.

Copilot uses AI. Check for mistakes.
@Hasan-Uddin Hasan-Uddin reopened this Dec 9, 2025
@Hasan-Uddin Hasan-Uddin removed their assignment Dec 9, 2025
@mihaduldev mihaduldev merged commit 6c3f634 into Dev Dec 9, 2025
@mihaduldev mihaduldev deleted the country_region branch December 9, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants