Files
cmc/support-portal-frontend/src/app/service/upcoming-events.service.ts
2025-09-23 19:41:25 +05:30

47 lines
1.3 KiB
TypeScript

// upcoming-events.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
export interface UpcomingEvent {
id?: number;
title: string;
description: string;
schedule: string;
eventDate?: string;
isActive: boolean;
}
@Injectable({
providedIn: 'root'
})
export class UpcomingEventsService {
private apiUrl = environment.apiUrl + '/api/upcoming-events';
constructor(private http: HttpClient) {}
getAllUpcomingEvents(): Observable<UpcomingEvent[]> {
return this.http.get<UpcomingEvent[]>(this.apiUrl);
}
getActiveUpcomingEvents(): Observable<UpcomingEvent[]> {
return this.http.get<UpcomingEvent[]>(`${this.apiUrl}/active`);
}
getUpcomingEvent(id: number): Observable<UpcomingEvent> {
return this.http.get<UpcomingEvent>(`${this.apiUrl}/${id}`);
}
createUpcomingEvent(event: UpcomingEvent): Observable<UpcomingEvent> {
return this.http.post<UpcomingEvent>(this.apiUrl, event);
}
updateUpcomingEvent(id: number, event: UpcomingEvent): Observable<UpcomingEvent> {
return this.http.put<UpcomingEvent>(`${this.apiUrl}/${id}`, event);
}
deleteUpcomingEvent(id: number): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}/${id}`);
}
}