code refactoring

This commit is contained in:
Bangara Raju Kottedi 2024-04-30 23:58:32 +05:30
parent bd2ec7272f
commit 9cfe5676bc
4 changed files with 76 additions and 54 deletions

View File

@ -44,7 +44,7 @@ namespace PortBlog.API.Controllers
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<ResumeDto>> Get(int candidateId)
public async Task<ActionResult<CvDto>> Get(int candidateId)
{
try
{
@ -56,7 +56,7 @@ namespace PortBlog.API.Controllers
var latestResumeForCandidate = await _resumeRepository.GetLatestResumeForCandidateAsync(candidateId, true);
return Ok(_mapper.Map<ResumeDto>(latestResumeForCandidate));
return Ok(_mapper.Map<CvDto>(latestResumeForCandidate));
}
catch (Exception ex)

View File

@ -0,0 +1,73 @@
namespace PortBlog.API.Models
{
/// <summary>
/// CV details of the candidate
/// </summary>
public class CvDto
{
/// <summary>
/// The id of the cv
/// </summary>
public int ResumeId { get; set; }
/// <summary>
/// The title of the candidate
/// </summary>
public string Title { get; set; } = string.Empty;
/// <summary>
/// A brief description about the candidate
/// </summary>
public string About { get; set; } = string.Empty;
/// <summary>
/// Candidate's information
/// </summary>
public CandidateDto? Candidate { get; set; }
/// <summary>
/// Candidate's Social Media links
/// </summary>
public SocialLinksDto? SocialLinks { get; set; }
/// <summary>
/// Candidate's blog posts
/// </summary>
public ICollection<PostDto> Posts
{
get
{
return SocialLinks?.Posts ?? new List<PostDto>();
}
}
/// <summary>
/// The education details of the candidate
/// </summary>
public ICollection<AcademicDto> Academics { get; set; } = new List<AcademicDto>();
/// <summary>
/// The skills of the candidate
/// </summary>
public ICollection<SkillDto> Skills { get; set; } = new List<SkillDto>();
/// <summary>
/// The work experiences of the candidate
/// </summary>
public ICollection<ExperienceDto> Experiences { get; set; } = new List<ExperienceDto>();
/// <summary>
/// The certifications done by the candidate
/// </summary>
public ICollection<CertificationDto> Certifications { get; set; } = new List<CertificationDto>();
/// <summary>
/// The hobbies of the candidate
/// </summary>
public ICollection<HobbyDto> Hobbies { get; set; } = new List<HobbyDto>();
/// <summary>
/// The projects of the candidate
/// </summary>
public ICollection<ProjectDto> Projects { get; set; } = new List<ProjectDto>();
/// <summary>
/// The project categories of all the projects
/// </summary>
public ICollection<string> ProjectsCategories
{
get
{
return Projects.Select(p => p.Category).Distinct().ToList();
}
}
}
}

View File

@ -5,36 +5,6 @@
/// </summary>
public class ResumeDto
{
/// <summary>
/// The id of the cv
/// </summary>
public int ResumeId { get; set; }
/// <summary>
/// The title of the candidate
/// </summary>
public string Title { get; set; } = string.Empty;
/// <summary>
/// A brief description about the candidate
/// </summary>
public string About { get; set; } = string.Empty;
/// <summary>
/// Candidate's information
/// </summary>
public CandidateDto? Candidate { get; set; }
/// <summary>
/// Candidate's Social Media links
/// </summary>
public SocialLinksDto? SocialLinks { get; set; }
/// <summary>
/// Candidate's blog posts
/// </summary>
public ICollection<PostDto> Posts
{
get
{
return SocialLinks?.Posts ?? new List<PostDto>();
}
}
/// <summary>
/// The education details of the candidate
/// </summary>
@ -47,27 +17,5 @@
/// The work experiences of the candidate
/// </summary>
public ICollection<ExperienceDto> Experiences { get; set; } = new List<ExperienceDto>();
/// <summary>
/// The certifications done by the candidate
/// </summary>
public ICollection<CertificationDto> Certifications { get; set; } = new List<CertificationDto>();
/// <summary>
/// The hobbies of the candidate
/// </summary>
public ICollection<HobbyDto> Hobbies { get; set; } = new List<HobbyDto>();
/// <summary>
/// The projects of the candidate
/// </summary>
public ICollection<ProjectDto> Projects { get; set; } = new List<ProjectDto>();
/// <summary>
/// The project categories of all the projects
/// </summary>
public ICollection<string> ProjectsCategories
{
get
{
return Projects.Select(p => p.Category).Distinct().ToList();
}
}
}
}

View File

@ -60,6 +60,7 @@ namespace PortBlog.API.Profiles
dest => dest.Posts,
src => src.MapFrom(src => src.Blog != null ? src.Blog.Posts : new List<Post>())
);
CreateMap<Resume, CvDto>();
CreateMap<Resume, ResumeDto>();
CreateMap<Resume, AboutDto>();
CreateMap<Resume, CandidateSocialLinksDto>();