67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { ICv } from '../models/cv.model';
|
|
import { Observable, Subject, of } from 'rxjs';
|
|
import { IAbout } from '../about/about.model';
|
|
import { IResume } from '../resume/resume.model';
|
|
import { IBlog } from '../blog/blog.model';
|
|
import { IProjects } from '../projects/projects.model';
|
|
import { ISideBar } from '../contact-sidebar/side-bar.model';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class CvService {
|
|
public cv!: ICv;
|
|
|
|
public about!: IAbout;
|
|
public candidateAndSocialLinks!: ISideBar;
|
|
public resume!: IResume;
|
|
public projects!: IProjects;
|
|
public blog!: IBlog;
|
|
|
|
constructor(private http: HttpClient) { }
|
|
|
|
getCv(candidateId: number): Observable<ICv> {
|
|
if(this.cv != null){
|
|
return of(this.cv);
|
|
}
|
|
return this.http.get<ICv>(`/api/cv/${candidateId}`);
|
|
}
|
|
|
|
getHobbies(candidateId: number): Observable<IAbout>{
|
|
if(this.about != null){
|
|
return of(this.about);
|
|
}
|
|
return this.http.get<IAbout>(`/api/cv/GetHobbies/${candidateId}`);
|
|
}
|
|
|
|
getCandidateWithSocialLinks(candidateId: number): Observable<ISideBar>{
|
|
if(this.candidateAndSocialLinks != null){
|
|
return of(this.candidateAndSocialLinks);
|
|
}
|
|
return this.http.get<ISideBar>(`/api/cv/GetCandidateWithSocialLinks/${candidateId}`);
|
|
}
|
|
|
|
getResume(candidateId: number): Observable<IResume>{
|
|
if(this.resume != null){
|
|
return of(this.resume);
|
|
}
|
|
return this.http.get<IResume>(`/api/cv/GetResume/${candidateId}`);
|
|
}
|
|
|
|
getProjects(candidateId: number): Observable<IProjects>{
|
|
if(this.projects != null){
|
|
return of(this.projects);
|
|
}
|
|
return this.http.get<ICv>(`/api/cv/GetProjects/${candidateId}`);
|
|
}
|
|
|
|
getBlog(candidateId: number): Observable<IBlog>{
|
|
if(this.blog != null){
|
|
return of(this.blog);
|
|
}
|
|
return this.http.get<IBlog>(`/api/cv/GetBlog/${candidateId}`);
|
|
}
|
|
}
|