-
Notifications
You must be signed in to change notification settings - Fork 1
main <- Dev (stable_4.1) #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
371a237
added feature country_region
MehediHasan19013 c560c72
Merge PR #97 from Dapplesoft-AD/Dev
Hasan-Uddin d8680ca
🔀 revert changes in appsettings.json
Hasan-Uddin 45fd7fa
migration fixed ✅
Hasan-Uddin 246e147
Fixed all issue
MehediHasan19013 6c3f634
Merge pull request #96 from Dapplesoft-AD/country_region
mihaduldev a402e5c
added area and localities feature
masum1438 53d983a
Resolve problems is area and localities
masum1438 b6a50ba
resolve problems in area and localities
masum1438 50f7958
Merge pull request #98 from Dapplesoft-AD/maasum-area-feature
mihaduldev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using Application.Abstractions.Messaging; | ||
| using Domain.Areas; | ||
|
|
||
| namespace Application.Areas.Create; | ||
|
|
||
| public sealed record CreateAreaCommand( | ||
| Guid CountryId, | ||
| Guid DistrictId, | ||
| string Name, | ||
| Area.AreaType Type, | ||
| bool IsActive | ||
| ) : ICommand<Guid>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using Application.Abstractions.Data; | ||
| using Application.Abstractions.Messaging; | ||
| using Domain; | ||
| using Domain.Areas; | ||
| using SharedKernel; | ||
|
|
||
| namespace Application.Areas.Create; | ||
|
|
||
| public sealed class CreateAreaCommandHandler | ||
| : ICommandHandler<CreateAreaCommand, Guid> | ||
| { | ||
| private readonly IApplicationDbContext _context; | ||
|
|
||
| public CreateAreaCommandHandler(IApplicationDbContext context) | ||
| { | ||
| _context = context; | ||
| } | ||
|
|
||
| public async Task<Result<Guid>> Handle( | ||
| CreateAreaCommand command, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| var area = new Area | ||
| { | ||
| CountryId = command.CountryId, | ||
| DistrictId = command.DistrictId, | ||
| Name = command.Name, | ||
| Type = command.Type, | ||
| IsActive = command.IsActive | ||
| }; | ||
|
|
||
| await _context.Areas.AddAsync(area, cancellationToken); | ||
| await _context.SaveChangesAsync(cancellationToken); | ||
|
|
||
| return Result.Success(area.Id); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System; | ||
| using FluentValidation; | ||
|
|
||
| namespace Application.Areas.Create; | ||
|
|
||
| public class CreateAreaValidator : AbstractValidator<CreateAreaCommand> | ||
| { | ||
| public CreateAreaValidator() | ||
| { | ||
| RuleFor(x => x.CountryId) | ||
| .NotEmpty() | ||
| .WithMessage("CountryId is required.") | ||
| .NotEqual(Guid.Empty) | ||
| .WithMessage("CountryId cannot be empty GUID."); | ||
|
|
||
| RuleFor(x => x.DistrictId) | ||
| .NotEmpty() | ||
| .WithMessage("ID is required.") | ||
| .NotEqual(Guid.Empty) | ||
| .WithMessage("DistrictId cannot be empty GUID."); | ||
|
|
||
| RuleFor(x => x.Name) | ||
| .NotEmpty() | ||
| .WithMessage("Name is required.") | ||
| .MaximumLength(255) | ||
| .WithMessage("Name must not exceed 255 characters."); | ||
|
|
||
| RuleFor(x => x.Type) | ||
| .IsInEnum() | ||
| .WithMessage( | ||
| "Invalid area type. Valid values: 1=Upazila, 2=City, 3=Thana, 4=Municipality, 5=Township." | ||
| ); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| using Application.Abstractions.Messaging; | ||
|
|
||
| namespace Application.Areas.Delete; | ||
|
|
||
| public sealed record DeleteAreaCommand(Guid Id) : ICommand; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using Application.Abstractions.Data; | ||
| using Application.Abstractions.Messaging; | ||
| using Domain.Areas; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using SharedKernel; | ||
|
|
||
| namespace Application.Areas.Delete; | ||
|
|
||
| public sealed class DeleteAreaCommandHandler | ||
| : ICommandHandler<DeleteAreaCommand> | ||
| { | ||
| private readonly IApplicationDbContext _context; | ||
|
|
||
| public DeleteAreaCommandHandler(IApplicationDbContext context) | ||
| { | ||
| _context = context; | ||
| } | ||
|
|
||
| public async Task<Result> Handle(DeleteAreaCommand command, CancellationToken cancellationToken) | ||
| { | ||
| Area? area = await _context.Areas | ||
| .FirstOrDefaultAsync(a => a.Id == command.Id, cancellationToken); | ||
|
|
||
| if (area is null) | ||
| { | ||
| return Result.Failure("Area not found."); | ||
| } | ||
|
|
||
| _context.Areas.Remove(area); | ||
| await _context.SaveChangesAsync(cancellationToken); | ||
|
|
||
| return Result.Success(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using System; | ||
| using FluentValidation; | ||
|
|
||
| namespace Application.Areas.Delete; | ||
|
|
||
| public class DeleteAreaValidator : AbstractValidator<DeleteAreaCommand> | ||
| { | ||
| public DeleteAreaValidator() | ||
| { | ||
| RuleFor(x => x.Id) | ||
| .NotEmpty() | ||
| .WithMessage("ID is required.") | ||
| .NotEqual(Guid.Empty) | ||
| .WithMessage("ID cannot be empty GUID."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| namespace Application.Areas.Get; | ||
|
|
||
| public sealed record AreaResponse( | ||
| Guid Id, | ||
| Guid CountryId, | ||
| Guid DistrictId, | ||
| string Name, | ||
| int Type, | ||
| string TypeName, | ||
| bool IsActive | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| using System; | ||
| using Application.Abstractions.Messaging; | ||
|
|
||
| namespace Application.Areas.Get; | ||
|
|
||
| public sealed record GetAreaByIdQuery(Guid Id) : IQuery<AreaResponse>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| using Application.Abstractions.Data; | ||
| using Application.Abstractions.Messaging; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using SharedKernel; | ||
|
|
||
| namespace Application.Areas.Get; | ||
|
|
||
| public sealed class GetAreaByIdQueryHandler | ||
| : IQueryHandler<GetAreaByIdQuery, AreaResponse> | ||
| { | ||
| private readonly IApplicationDbContext _context; | ||
|
|
||
| public GetAreaByIdQueryHandler(IApplicationDbContext context) | ||
| { | ||
| _context = context; | ||
| } | ||
|
|
||
| public async Task<Result<AreaResponse>> Handle( | ||
| GetAreaByIdQuery query, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| AreaResponse? area = await _context.Areas.Where(a => a.Id == query.Id) | ||
| .Select(a => new AreaResponse( | ||
| a.Id, | ||
| a.CountryId, | ||
| a.DistrictId, | ||
| a.Name, | ||
| (int)a.Type, | ||
| a.Type.ToString(), | ||
| a.IsActive | ||
| )) | ||
| .FirstOrDefaultAsync(cancellationToken); | ||
|
|
||
| if (area is null) | ||
| { | ||
| return Result.Failure<AreaResponse>("Area not found."); | ||
| } | ||
|
|
||
| return Result.Success(area); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| using Application.Abstractions.Messaging; | ||
| using Application.Areas.Get; | ||
|
|
||
| namespace Application.Areas.GetAll; | ||
|
|
||
| public sealed record GetAllAreasQuery() : IQuery<List<AreaResponse>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||
| using Application.Abstractions.Data; | ||||
| using Application.Abstractions.Messaging; | ||||
| using Application.Areas.Get; | ||||
| using Application.Areas.GetAll; | ||||
|
||||
| using Application.Areas.GetAll; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using Application.Abstractions.Messaging; | ||
| using Domain.Areas; | ||
|
|
||
| namespace Application.Areas.Update; | ||
|
|
||
| public sealed record UpdateAreaCommand( | ||
| Guid Id, | ||
| Guid CountryId, | ||
| Guid DistrictId, | ||
| string Name, | ||
| Area.AreaType Type, | ||
| bool IsActive | ||
| ) : ICommand<Guid>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using Application.Abstractions.Data; | ||
| using Application.Abstractions.Messaging; | ||
| using Domain.Areas; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using SharedKernel; | ||
|
|
||
| namespace Application.Areas.Update; | ||
|
|
||
| public sealed class UpdateAreaCommandHandler | ||
| : ICommandHandler<UpdateAreaCommand, Guid> | ||
| { | ||
| private readonly IApplicationDbContext _context; | ||
|
|
||
| public UpdateAreaCommandHandler(IApplicationDbContext context) | ||
| { | ||
| _context = context; | ||
| } | ||
|
|
||
| public async Task<Result<Guid>> Handle( | ||
| UpdateAreaCommand command, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| Area? area = await _context.Areas | ||
| .FirstOrDefaultAsync(a => a.Id == command.Id, cancellationToken); | ||
|
|
||
| if (area is null) | ||
| { | ||
| return Result.Failure<Guid>("Area not found."); | ||
| } | ||
|
|
||
| // Check if area name is unique within the same district (excluding current area) | ||
| bool areaNameExists = await _context.Areas | ||
| .AnyAsync(a => | ||
| a.DistrictId == command.DistrictId && | ||
| a.Name == command.Name && | ||
| a.Id != command.Id, | ||
| cancellationToken); | ||
|
|
||
| if (areaNameExists) | ||
| { | ||
| return Result.Failure<Guid>("Area name already exists in this district."); | ||
| } | ||
|
|
||
| // Update properties | ||
| area.CountryId = command.CountryId; | ||
| area.DistrictId = command.DistrictId; | ||
| area.Name = command.Name; | ||
| area.Type = command.Type; | ||
| area.IsActive = command.IsActive; | ||
|
|
||
| await _context.SaveChangesAsync(cancellationToken); | ||
|
|
||
| return Result.Success(area.Id); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty folder item in project file: The Applications\Delete folder item appears to be empty or incorrectly configured. This should either be removed or the proper files should be added to this folder.