code refactoring
This commit is contained in:
parent
bd2ec7272f
commit
9cfe5676bc
@ -44,7 +44,7 @@ namespace PortBlog.API.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<ResumeDto>> Get(int candidateId)
|
public async Task<ActionResult<CvDto>> Get(int candidateId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace PortBlog.API.Controllers
|
|||||||
|
|
||||||
var latestResumeForCandidate = await _resumeRepository.GetLatestResumeForCandidateAsync(candidateId, true);
|
var latestResumeForCandidate = await _resumeRepository.GetLatestResumeForCandidateAsync(candidateId, true);
|
||||||
|
|
||||||
return Ok(_mapper.Map<ResumeDto>(latestResumeForCandidate));
|
return Ok(_mapper.Map<CvDto>(latestResumeForCandidate));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
73
PortBlog.API/Models/CvDto.cs
Normal file
73
PortBlog.API/Models/CvDto.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,36 +5,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ResumeDto
|
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>
|
/// <summary>
|
||||||
/// The education details of the candidate
|
/// The education details of the candidate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -47,27 +17,5 @@
|
|||||||
/// The work experiences of the candidate
|
/// The work experiences of the candidate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ICollection<ExperienceDto> Experiences { get; set; } = new List<ExperienceDto>();
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,6 +60,7 @@ namespace PortBlog.API.Profiles
|
|||||||
dest => dest.Posts,
|
dest => dest.Posts,
|
||||||
src => src.MapFrom(src => src.Blog != null ? src.Blog.Posts : new List<Post>())
|
src => src.MapFrom(src => src.Blog != null ? src.Blog.Posts : new List<Post>())
|
||||||
);
|
);
|
||||||
|
CreateMap<Resume, CvDto>();
|
||||||
CreateMap<Resume, ResumeDto>();
|
CreateMap<Resume, ResumeDto>();
|
||||||
CreateMap<Resume, AboutDto>();
|
CreateMap<Resume, AboutDto>();
|
||||||
CreateMap<Resume, CandidateSocialLinksDto>();
|
CreateMap<Resume, CandidateSocialLinksDto>();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user