From 9cfe5676bc4ccf02654f4dffd0056ea671941409 Mon Sep 17 00:00:00 2001 From: Bangara Raju Kottedi Date: Tue, 30 Apr 2024 23:58:32 +0530 Subject: [PATCH] code refactoring --- PortBlog.API/Controllers/CvController.cs | 4 +- PortBlog.API/Models/CvDto.cs | 73 ++++++++++++++++++++++++ PortBlog.API/Models/ResumeDto.cs | 52 ----------------- PortBlog.API/Profiles/ResumeProfile.cs | 1 + 4 files changed, 76 insertions(+), 54 deletions(-) create mode 100644 PortBlog.API/Models/CvDto.cs diff --git a/PortBlog.API/Controllers/CvController.cs b/PortBlog.API/Controllers/CvController.cs index cc03ced..1fa1e01 100644 --- a/PortBlog.API/Controllers/CvController.cs +++ b/PortBlog.API/Controllers/CvController.cs @@ -44,7 +44,7 @@ namespace PortBlog.API.Controllers [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task> Get(int candidateId) + public async Task> Get(int candidateId) { try { @@ -56,7 +56,7 @@ namespace PortBlog.API.Controllers var latestResumeForCandidate = await _resumeRepository.GetLatestResumeForCandidateAsync(candidateId, true); - return Ok(_mapper.Map(latestResumeForCandidate)); + return Ok(_mapper.Map(latestResumeForCandidate)); } catch (Exception ex) diff --git a/PortBlog.API/Models/CvDto.cs b/PortBlog.API/Models/CvDto.cs new file mode 100644 index 0000000..57a467c --- /dev/null +++ b/PortBlog.API/Models/CvDto.cs @@ -0,0 +1,73 @@ +namespace PortBlog.API.Models +{ + /// + /// CV details of the candidate + /// + public class CvDto + { + /// + /// The id of the cv + /// + public int ResumeId { get; set; } + /// + /// The title of the candidate + /// + public string Title { get; set; } = string.Empty; + /// + /// A brief description about the candidate + /// + public string About { get; set; } = string.Empty; + /// + /// Candidate's information + /// + public CandidateDto? Candidate { get; set; } + /// + /// Candidate's Social Media links + /// + public SocialLinksDto? SocialLinks { get; set; } + /// + /// Candidate's blog posts + /// + public ICollection Posts + { + get + { + return SocialLinks?.Posts ?? new List(); + } + } + /// + /// The education details of the candidate + /// + public ICollection Academics { get; set; } = new List(); + /// + /// The skills of the candidate + /// + public ICollection Skills { get; set; } = new List(); + /// + /// The work experiences of the candidate + /// + public ICollection Experiences { get; set; } = new List(); + /// + /// The certifications done by the candidate + /// + public ICollection Certifications { get; set; } = new List(); + /// + /// The hobbies of the candidate + /// + public ICollection Hobbies { get; set; } = new List(); + /// + /// The projects of the candidate + /// + public ICollection Projects { get; set; } = new List(); + /// + /// The project categories of all the projects + /// + public ICollection ProjectsCategories + { + get + { + return Projects.Select(p => p.Category).Distinct().ToList(); + } + } + } +} diff --git a/PortBlog.API/Models/ResumeDto.cs b/PortBlog.API/Models/ResumeDto.cs index 173f40e..ab84532 100644 --- a/PortBlog.API/Models/ResumeDto.cs +++ b/PortBlog.API/Models/ResumeDto.cs @@ -5,36 +5,6 @@ /// public class ResumeDto { - /// - /// The id of the cv - /// - public int ResumeId { get; set; } - /// - /// The title of the candidate - /// - public string Title { get; set; } = string.Empty; - /// - /// A brief description about the candidate - /// - public string About { get; set; } = string.Empty; - /// - /// Candidate's information - /// - public CandidateDto? Candidate { get; set; } - /// - /// Candidate's Social Media links - /// - public SocialLinksDto? SocialLinks { get; set; } - /// - /// Candidate's blog posts - /// - public ICollection Posts - { - get - { - return SocialLinks?.Posts ?? new List(); - } - } /// /// The education details of the candidate /// @@ -47,27 +17,5 @@ /// The work experiences of the candidate /// public ICollection Experiences { get; set; } = new List(); - /// - /// The certifications done by the candidate - /// - public ICollection Certifications { get; set; } = new List(); - /// - /// The hobbies of the candidate - /// - public ICollection Hobbies { get; set; } = new List(); - /// - /// The projects of the candidate - /// - public ICollection Projects { get; set; } = new List(); - /// - /// The project categories of all the projects - /// - public ICollection ProjectsCategories - { - get - { - return Projects.Select(p => p.Category).Distinct().ToList(); - } - } } } diff --git a/PortBlog.API/Profiles/ResumeProfile.cs b/PortBlog.API/Profiles/ResumeProfile.cs index 8841e13..31ad2a3 100644 --- a/PortBlog.API/Profiles/ResumeProfile.cs +++ b/PortBlog.API/Profiles/ResumeProfile.cs @@ -60,6 +60,7 @@ namespace PortBlog.API.Profiles dest => dest.Posts, src => src.MapFrom(src => src.Blog != null ? src.Blog.Posts : new List()) ); + CreateMap(); CreateMap(); CreateMap(); CreateMap();