Commit e81337ba authored by hasan khaddour's avatar hasan khaddour

add project serivce

parent 93f2c422
export interface AddAttachmentRequest {
projectId: number;
attachmentDescription: string;
attachmentName: string;
file: File;
}
export interface AddParticipantRequest {
projectId: number;
participantId: number;
partialTimeRatio: number;
role: string;
}
import { StepInfo } from "../../valueObjects/StepInfo";
export class AddProjectStepRequest {
projectId: number;
stepInfo: StepInfo;
currentCompletionRatio: number;
weight: number;
}
export interface CancelProjectRequest {
employeeId: number
projectId: number
}
export interface ChangeProjectManagerRequest {
employeeId: number;
projectId: number;
}
export interface ChangeProjectTeamLeaderRequest {
employeeId: number;
projectId: number;
}
export interface GetProjectAttachmentsRequest {
projectId: number;
pageNumber: number | null;
pageSize: number | null;
}
export interface GetProjectsByProjectManagerRequest {
projectMangerId: number;
pageNumber: number | null;
pageSize: number | null;
}
export interface RePlanProjectRequest {
projectId: number;
}
export interface RemoveParticipantRequest {
ParticipantId: number;
projectId: number;
}
export interface ChangeStepWeightRequest {
stepId :number
weight :number
}
export class GetStepTrackHistoryRequest {
stepId: number;
pageSize: number | null;
pageNumber: number | null;
}
export class GetStepsByProjectRequest {
projectId: number;
pageSize: number | null;
pageNumber: number | null;
}
export class UpdateCompletionRatioRequest {
stepId: number;
completionRatio: number;
}
export interface Attachment {
projectId: number;
attachmentUrl: string;
attachmentDescription: string;
attachmentName: string;
}
...@@ -8,7 +8,6 @@ import { ProposalInfo } from "../valueObjects/proposalInfo" ...@@ -8,7 +8,6 @@ import { ProposalInfo } from "../valueObjects/proposalInfo"
import { ProjectClassification } from "../valueObjects/ProjectClassification" import { ProjectClassification } from "../valueObjects/ProjectClassification"
import { Department } from "./Department" import { Department } from "./Department"
import { Step } from "./Step" import { Step } from "./Step"
export class Project export class Project
{ {
id:number id:number
......
...@@ -4,6 +4,18 @@ import { ConfigurationService } from '../../core/services/configuration/configur ...@@ -4,6 +4,18 @@ import { ConfigurationService } from '../../core/services/configuration/configur
import { Project } from '../models/responses/project'; import { Project } from '../models/responses/project';
import { Result } from '../../core/models/result'; import { Result } from '../../core/models/result';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { GetProjectsByProjectManagerRequest } from '../models/requests/project-requests/GetProjectsByProjectManagerRequest';
import { EmployeeParticipate } from '../../employees/models/responses/employeeParticipate';
import { ChangeProjectTeamLeaderRequest } from '../models/requests/project-requests/ChangeProjectTeamLeaderRequest';
import { ChangeProjectManagerRequest } from '../models/requests/project-requests/ChangeProjectManagerRequest';
import { AddProjectStepRequest } from '../models/requests/project-requests/AddProjectStepRequest';
import { RemoveParticipantRequest } from '../models/requests/project-requests/RemoveParticipant';
import { AddParticipantRequest } from '../models/requests/project-requests/AddParticipantRequest';
import { CancelProjectRequest } from '../models/requests/project-requests/CancelProjectRequest';
import { RePlanProjectRequest } from '../models/requests/project-requests/RePlanProjectRequest';
import { CreateProjectRequest } from '../models/requests/project-requests/createProjectRequest';
import { AddAttachmentRequest } from '../models/requests/project-requests/AddAttachmentRequest';
import { Attachment } from '../models/responses/Attachment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -12,14 +24,181 @@ export class ProjectService { ...@@ -12,14 +24,181 @@ export class ProjectService {
constructor(private http :HttpClient ,private config : ConfigurationService) { } constructor(private http :HttpClient ,private config : ConfigurationService) { }
//#region queries
// the filters options are
// -- department name
// -- first name
// -- project manager
// -- team leader
// --
public getByFilter():Observable<Project[]>{ public getByFilter():Observable<Project[]>{
return this.http.get<Project[]>(this.config.getServerUrl()+ "/Projects/ByFilter"); return this.http.get<Project[]>(this.config.getServerUrl()+ "/Projects/ByFilter");
} }
public getAll(pageSize : number | null , pageNumber :number |null):Observable<Project[]>{
let pagination= this.getPagination(pageSize,pageNumber);
return this.http.get<Project[]>(this.config.getServerUrl()+ "/Projects"+pagination);
}
// this method reponsible for geting the specificed projet by its id
//
public getProjectById(id : number ):Observable<Project>{ public getProjectById(id : number ):Observable<Project>{
return this.http.get<Project>(this.config.getServerUrl()+ "/Projects/"+id); return this.http.get<Project>(this.config.getServerUrl()+ "/Projects/"+id);
} }
// this method retreive the projects by its manager
public getByProjectManger(request : GetProjectsByProjectManagerRequest ):Observable<Project[]>{
let pagination =this.getPagination(request.pageSize,request.pageNumber);
return this
.http
.get<Project[]>(`
${this.config.getServerUrl()}
/Projects/ByProjectManager/?projectManagerId=${request.projectMangerId}${pagination}`);
}
//#endregion queries
//#region planning managment
//tihs method responsible for hanging the team leader
//
public changeTeamLeader(request : ChangeProjectTeamLeaderRequest ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/ChangeProjectTeamLeader",request);
}
//tihs method responsible for changing the project manager
//
public changeProjectManager(request : ChangeProjectManagerRequest ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/ChangeProjectManager",request);
}
//tihs method responsible for add a new step to the project
//
public addStepToProject(request : AddProjectStepRequest ):Observable<number>{
return this.http.post<number>(this.config.getServerUrl()+ "/Projects/AddProjetStep",request);
}
//#endregion planning managment
//#region participants managment
// this method responsible for get the participants of a project
//
public getParticipants(projectId : number ):Observable<EmployeeParticipate[]>{
return this.http.get<EmployeeParticipate[]>(this.config.getServerUrl()+ "/Projects/GetParticipants/"+projectId);
}
//tihs method responsible for remove a participant of the project
//
public removeParticipant(request : RemoveParticipantRequest ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/RemoveParticipant",request);
}
//tihs method responsible for adda new participant to the project
//
public addParticipant(request : AddParticipantRequest ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/AddParticipant",request);
}
//#endregion participants managment
//#region state management
//tihs method responsible for change the state of the project from in plan to in progresss
//
public approveProject(projectId : number ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/ApproveProject",{projectId});
}
//tihs method responsible for cancel the project
//
public cancelProject(request : CancelProjectRequest ):Observable<void>{
return this.http.post<void>(`${this.config.getServerUrl()}/Projects/CancelProject/${request.projectId}`,request);
}
//tihs method responsible for changing the state of the project from in progress to in plan
//
public rePlanProject(request : RePlanProjectRequest ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/RePlanProject",request);
}
//tihs method responsible for changing the state of the project to completed
//
public completeProject(projectId : number ):Observable<void>{
return this.http.post<void>(this.config.getServerUrl()+ "/Projects/CompleteProject/"+projectId,{});
}
//tihs method responsible for creating a new project
//
public createProject(request : CreateProjectRequest ):Observable<Project>{
return this.http.post<Project>(this.config.getServerUrl()+ "/Projects/",request);
}
//#endregion state management
//#region attachments
//tihs method responsible for adding an atachment to the project
//
public addAttachment(request : AddAttachmentRequest ):Observable<number>{
return this.http.post<number>(this.config.getServerUrl()+ "/Projects/AddAttachment",request);
}
//tihs method responsible for getting the attachments of a project
//
public getAttachment(projectId : number ):Observable<Attachment[]>{
return this.http.get<Attachment[]>(this.config.getServerUrl()+ "/Projects/Attachmetns/"+projectId);
}
//#endregion attachments
//#region pagination convert
private getPagination( pageSize:number | null , pageNumber : number |null ){
if(pageNumber == null || pageSize == null){
return "";
}
else {
return `&pageSize=${pageSize}&PageNumber=${pageNumber}`;
}
}
//#endregion pagination convert
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment