import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { UnidadInformacion } from '../models/unidad-informacion.model'; @Injectable({ providedIn: 'root' }) export class UnidadInformacionService { private apiUrl = 'api/unidades'; constructor(private http: HttpClient) {} getUnidades(): Observable { return this.http.get(this.apiUrl); } getUnidadById(id: number): Observable { return this.http.get(`${this.apiUrl}/${id}`); } createUnidad(unidad: UnidadInformacion): Observable { return this.http.post(this.apiUrl, unidad); } updateUnidad(unidad: UnidadInformacion): Observable { return this.http.put(`${this.apiUrl}/${unidad.id}`, unidad); } deleteUnidad(id: number): Observable { return this.http.delete(`${this.apiUrl}/${id}`); } }