import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Config } from '../../_helpers/config.class'; import { ApplicationMaster, ApplicationAttachment, ApplicationLog } from '../application-fts/application-fts'; @Injectable() export class OrderService { constructor(private http: HttpClient) { } public getOrders(query: any, district: string, transferTypeId: number, currentPage: number, itemsPerPage: number) { return this.http.post(`${Config.getControllerUrl('TransferAndPosting', 'GetESRReport')}/${district}/${transferTypeId}/${currentPage}/${itemsPerPage}`, query); } public getApplications(skip: number, pageSize: number, query: string, typeId: number, statusId: number) { return this.http.post(`${Config.getControllerUrl('Application', 'GetApplications')}`, { Skip: skip, PageSize: pageSize, Type_Id: typeId, Status_Id: statusId, Query: query }); } public submitApplication(application: ApplicationMaster) { return this.http.post(`${Config.getControllerUrl('Application', 'SubmitApplication')}`, application); } public uploadApplicationAttachments(applicationAttachments: ApplicationAttachment[], appId: number) { const formData = new FormData(); applicationAttachments.forEach(attachment => { for (let key in attachment.files) { if (attachment.files.hasOwnProperty(key)) { let element = attachment.files[key]; formData.append('file_' + attachment.Document_Id, element); } } }); return this.http.post(`${Config.getControllerUrl('Application', 'UploadApplicationAttachments')}/${appId}`, formData); } public uploadSignedApplication(signedApplication: ApplicationAttachment, appId: number) { const formData = new FormData(); for (let key in signedApplication.files) { if (signedApplication.files.hasOwnProperty(key)) { let element = signedApplication.files[key]; formData.append('file', element); } } return this.http.post(`${Config.getControllerUrl('Application', 'UploadSignedApplication')}/${appId}`, formData); } public createApplicationLog(applicationLog: ApplicationLog) { return this.http.post(`${Config.getControllerUrl('Application', 'CreateApplicationLog')}`, applicationLog); } public submitFileMovement(applications: ApplicationMaster[]) { return this.http.post(`${Config.getControllerUrl('Application', 'SubmitFileMovement')}`, applications); } public searchProfile(cnic: string) { return this.http.get(`${Config.getControllerUrl('Application', 'SearchProfile')}/${cnic}`); } }