code refactoring

This commit is contained in:
Bangara Raju Kottedi 2024-05-02 17:57:56 +05:30
parent 62c7a29909
commit cd1ad0a47f
4 changed files with 7 additions and 5 deletions

View File

@ -69,7 +69,7 @@
var projectCategories = new List<string>();
foreach (var project in Projects)
{
projectCategories.AddRange(project.Categories);
projectCategories.AddRange(project.CategoryList);
}
return projectCategories.Distinct().ToList();
}

View File

@ -10,7 +10,9 @@ namespace PortBlog.API.Models
public string Description { get; set; } = string.Empty;
public ICollection<string> Categories { get; set; } = new List<string>();
public string Categories { get; set; } = string.Empty;
public ICollection<string> CategoryList { get; set; } = new List<string>();
public ICollection<string> Roles { get; set; } = new List<string>();

View File

@ -11,7 +11,7 @@
var projectCategories = new List<string>();
foreach(var project in Projects)
{
projectCategories.AddRange(project.Categories);
projectCategories.AddRange(project.CategoryList);
}
return projectCategories.Distinct().ToList();
}

View File

@ -55,8 +55,8 @@ namespace PortBlog.API.Profiles
)
.ForMember
(
dest => dest.Categories,
src => src.MapFrom(src => !string.IsNullOrEmpty(src.Categories) ? src.Categories.Split(",", StringSplitOptions.TrimEntries | StringSplitOptions.TrimEntries).ToList() : new List<string>())
dest => dest.CategoryList,
src => src.MapFrom(src => !string.IsNullOrEmpty(src.Categories) ? src.Categories.Split(",", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList() : new List<string>())
);
CreateMap<Skill, SkillDto>();