-
Notifications
You must be signed in to change notification settings - Fork 1
Hotfixes #109
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
Hotfixes #109
Changes from all commits
fa83401
4f84ccf
2333c44
871863d
d5c5a65
ebadf21
0c7c363
15fe0d7
219ebc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| namespace Dentizone.Application | ||
| { | ||
| public static class AssemblyReference | ||
| /// <summary> | ||
| /// Marker interface for the Application assembly, | ||
| /// used by AutoMapper to locate and load its profiles. | ||
| /// </summary> | ||
| public interface IAssemblyReference | ||
| { | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,23 +12,23 @@ public CartProfile() | |||||||||||
| .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) | ||||||||||||
| .ForMember(dest => dest.PostId, opt => opt.MapFrom(src => src.PostId)) | ||||||||||||
| .ForMember(dest => dest.Post, opt => opt.MapFrom(src => new Post | ||||||||||||
| { | ||||||||||||
| Title = src.Title, | ||||||||||||
| Price = src.Price, | ||||||||||||
| PostAssets = new List<PostAsset> | ||||||||||||
| { | ||||||||||||
| new PostAsset | ||||||||||||
| { | ||||||||||||
| Asset = new Domain.Entity.Asset | ||||||||||||
| { | ||||||||||||
| Url = src.Url | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| })) | ||||||||||||
| { | ||||||||||||
| Title = src.Title, | ||||||||||||
| Price = src.Price, | ||||||||||||
| PostAssets = new List<PostAsset> | ||||||||||||
| { | ||||||||||||
| new() | ||||||||||||
| { | ||||||||||||
| Asset = new Domain.Entity.Asset | ||||||||||||
| { | ||||||||||||
| Url = src.Url | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| })) | ||||||||||||
| .ReverseMap() | ||||||||||||
| .ForMember(dest => dest.Url, opt => opt.MapFrom(src => | ||||||||||||
| src.Post.PostAssets.FirstOrDefault().Asset.Url)) | ||||||||||||
| src.Post.PostAssets.FirstOrDefault().Asset.Url)) | ||||||||||||
|
Comment on lines
30
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix potential null reference exception in reverse mapping. The current code could throw a Apply this fix to handle null cases safely: - .ForMember(dest => dest.Url, opt => opt.MapFrom(src =>
- src.Post.PostAssets.FirstOrDefault().Asset.Url))
+ .ForMember(dest => dest.Url, opt => opt.MapFrom(src =>
+ src.Post.PostAssets.FirstOrDefault()?.Asset?.Url ?? string.Empty))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Post.Title)) | ||||||||||||
| .ForMember(dest => dest.Price, opt => opt.MapFrom(src => src.Post.Price)); | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| using AutoMapper; | ||
| using Dentizone.Application.DTOs.UserActivityDTO; | ||
| using Dentizone.Application.DTOs.UserActivity; | ||
| using Dentizone.Domain.Entity; | ||
|
|
||
| namespace Dentizone.Application.AutoMapper | ||
|
|
@@ -9,7 +9,7 @@ public class UserActivityProfile : Profile | |
| public UserActivityProfile() | ||
| { | ||
| CreateMap<CreatedUserActivityDto, UserActivity>().ReverseMap(); | ||
| CreateMap<UserActivityDTO, UserActivity>() | ||
| CreateMap<UserActivityDto, UserActivity>() | ||
| .ReverseMap() | ||
| .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.User.Username)); | ||
|
Comment on lines
+12
to
14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against null
- .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.User.Username));
+ .ForMember(dest => dest.UserName,
+ opt => opt.MapFrom(src => src.User?.Username));Consider also adding 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,13 +18,13 @@ public UserProfile() | |||||||||||||||||||||||||||||
| CreateMap<CreateAppUser, AppUser>() | ||||||||||||||||||||||||||||||
| .ReverseMap(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| CreateMap<KycStatusDTO, AppUser>().ReverseMap(); | ||||||||||||||||||||||||||||||
| CreateMap<UserStateDTO, AppUser>() | ||||||||||||||||||||||||||||||
| CreateMap<KycStatusDto, AppUser>().ReverseMap(); | ||||||||||||||||||||||||||||||
| CreateMap<UserStateDto, AppUser>() | ||||||||||||||||||||||||||||||
| .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status)) | ||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partial-DTO mapping risks overriding unrelated fields – ignore the rest explicitly
Add explicit member mapping and ignore everything else: -CreateMap<KycStatusDto, AppUser>().ReverseMap();
-CreateMap<UserStateDto, AppUser>()
- .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status))
- .ReverseMap()
- .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status));
+CreateMap<KycStatusDto, AppUser>()
+ .ForMember(dest => dest.KycStatus, opt => opt.MapFrom(src => src.KycStatus))
+ .ForAllOtherMembers(opt => opt.Ignore())
+ .ReverseMap();
+
+CreateMap<UserStateDto, AppUser>()
+ .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status))
+ .ForAllOtherMembers(opt => opt.Ignore())
+ .ReverseMap()
+ .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status));Same pattern should be applied wherever a “single-purpose” DTO maps to the full 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| .ReverseMap() | ||||||||||||||||||||||||||||||
| .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status)); | ||||||||||||||||||||||||||||||
| CreateMap<UserView, AppUser>() | ||||||||||||||||||||||||||||||
| .ForPath(dest => dest.University.Name, opt => opt.MapFrom(src => src.UnversityName)) | ||||||||||||||||||||||||||||||
| .ForPath(dest => dest.University.Name, opt => opt.MapFrom(src => src.UniversityName)) | ||||||||||||||||||||||||||||||
| .ReverseMap(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| CreateMap<DomainUserView, AppUser>() | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,13 @@ namespace Dentizone.Application.DTOs.Catalog | |
| { | ||
| public class CategoryView | ||
| { | ||
| public string Id { get; set; } | ||
| public string Name { get; set; } | ||
| public required string Id { get; set; } | ||
| public required string Name { get; set; } | ||
| } | ||
|
|
||
| public class CreatedCategoryDTOValidator : AbstractValidator<CategoryView> | ||
| public class CreatedCategoryDtoValidator : AbstractValidator<CategoryView> | ||
| { | ||
| public CreatedCategoryDTOValidator() | ||
| public CreatedCategoryDtoValidator() | ||
|
Comment on lines
+11
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Validator name/type mismatch can cause confusion
- public class CreatedCategoryDtoValidator : AbstractValidator<CategoryView>
+ public class CategoryViewValidator : AbstractValidator<CategoryView>🤖 Prompt for AI Agents |
||
| { | ||
| RuleFor(x => x.Name) | ||
| .NotEmpty().WithMessage("Category name is required.") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| using Dentizone.Application.DTOs.PostDTO; | ||
| using Dentizone.Application.DTOs.Post; | ||
|
|
||
| namespace Dentizone.Application.DTOs.Favorites | ||
| { | ||
| public class FavoriteViewDto | ||
| { | ||
| public string Id { get; set; } | ||
| public PostViewDto Post { get; set; } = new PostViewDto(); | ||
| public string Id { get; set; } = string.Empty; | ||
| public PostViewDto Post { get; set; } = new(); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.