Files
doneit-web/src/app/services/Repositorys/Agenda/agenda-data.service.ts
T

139 lines
4.8 KiB
TypeScript
Raw Normal View History

2024-05-29 15:45:34 +01:00
import { HttpClient, HttpParams } from '@angular/common/http';
2024-05-27 14:20:05 +01:00
import { Injectable } from '@angular/core';
2024-05-29 15:45:34 +01:00
import { Observable } from 'rxjs';
2024-05-30 10:20:46 +01:00
import { EventInputDTO } from './model/eventInputDTO';
2024-06-06 10:26:34 +01:00
import { SessionStore } from 'src/app/store/session.service';
import { SharedCalendarListOutputDTO, SharedCalendarListOutputDTOSchema } from './model/sharedCalendarOutputDTO';
import { HttpService } from '../../http.service';
import { APIReturn } from '../../decorator/api-validate-schema.decorator';
2024-05-27 14:20:05 +01:00
@Injectable({
providedIn: 'root'
})
2024-05-27 15:53:13 +01:00
2024-05-27 14:20:05 +01:00
export class AgendaDataService {
2024-05-29 15:45:34 +01:00
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
2024-05-27 14:20:05 +01:00
2024-06-06 10:26:34 +01:00
constructor(
private http: HttpClient,
private httpService: HttpService
) { }
2024-05-29 15:45:34 +01:00
getContacts(value: string): Observable<any> {
const params = new HttpParams().set('value', value);
return this.http.get<any>(`${this.baseUrl}/Contacts`, { params });
}
// Documents Endpoints
getAttachments(subject: string, applicationType: number): Observable<any> {
const params = new HttpParams()
.set('Subject', subject)
.set('ApplicationType', applicationType.toString());
return this.http.get<any>(`${this.baseUrl}/Documents/Attachments`, { params });
}
viewDocument(userId: number, docId: number, applicationId: number): Observable<any> {
const params = new HttpParams()
.set('userId', userId.toString())
.set('docId', docId.toString())
.set('applicationId', applicationId.toString());
return this.http.get<any>(`${this.baseUrl}/Documents/view`, { params });
}
// Events Endpoints
2024-06-07 10:26:26 +01:00
createEvent(eventData: EventInputDTO) {
2024-05-29 15:45:34 +01:00
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
}
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string): Observable<any> {
2024-05-31 09:45:30 +01:00
let params = new HttpParams()
2024-05-29 15:45:34 +01:00
.set('UserId', userId)
2024-05-31 09:45:30 +01:00
2024-06-07 10:26:26 +01:00
if(userId == null || userId == undefined) {
throw('userId '+ userId)
}
2024-06-13 16:01:33 +01:00
2024-06-17 10:33:35 +01:00
if(status != null || status != undefined) {
2024-06-13 16:01:33 +01:00
params = params.set('status', status);
}
2024-06-17 10:33:35 +01:00
2024-05-31 09:45:30 +01:00
if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate);
}
if (endDate !== null && endDate !== undefined) {
params = params.set('endDate', endDate);
}
2024-05-29 15:45:34 +01:00
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
}
2024-05-29 16:06:48 +01:00
getEvent(id: string): Observable<any> {
return this.http.get<any>(`${this.baseUrl}/Events/${id}`);
}
2024-05-29 15:45:34 +01:00
updateEvent(id: string, eventData: any): Observable<any> {
return this.http.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
}
approveEvent(id: string): Observable<any> {
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Approval`, {});
}
deleteEvent(id: string, deleteAllEvents: boolean): Observable<any> {
const params = new HttpParams().set('DeleteAllEvents', deleteAllEvents.toString());
return this.http.delete<any>(`${this.baseUrl}/Events/${id}`, { params });
}
updateEventStatus(id: string, statusData: any): Observable<any> {
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
}
addEventAttendee(id: string, attendeeData: any): Observable<any> {
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Attendee`, attendeeData);
}
removeEventAttendee(id: string, attendeeData: any): Observable<any> {
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attendee`, { body: attendeeData });
}
addEventAttachment(id: string, attachmentData: any): Observable<any> {
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Attachment`, attachmentData);
}
removeEventAttachment(id: string, attachmentData: any): Observable<any> {
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attachment`, { body: attachmentData });
}
communicateEvent(id: string, communicationData: any): Observable<any> {
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Communicate`, communicationData);
}
// Users Endpoints
getUsers(value: string): Observable<any> {
const params = new HttpParams().set('value', value);
return this.http.get<any>(`${this.baseUrl}/Users`, { params });
}
2024-05-29 16:06:48 +01:00
2024-05-29 15:45:34 +01:00
getToken(): Observable<any> {
return this.http.get<any>(`${this.baseUrl}/Users/token`);
}
2024-06-02 13:53:46 +01:00
getDocumentAttachment(aplicationId,userId,value,PageNumber,PageSize): Observable<any> {
const params = new HttpParams()
.set('userId', userId)
.set('Value', value)
.set('PageNumber', PageNumber)
.set('PageSize', PageSize);
return this.http.get<any>(`${this.baseUrl}/Documents/Attachments${aplicationId}`, {params});
}
2024-06-06 10:26:34 +01:00
@APIReturn(SharedCalendarListOutputDTOSchema)
async getSharedCalendar() {
2024-06-11 16:23:09 +01:00
return await this.httpService.get<SharedCalendarListOutputDTO>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/ShareCalendar`);
2024-06-06 10:26:34 +01:00
}
2024-05-27 14:20:05 +01:00
}