Commit 3adaa773 by DESKTOP-E0VCCBD\zedan

Update services

parent c797b756
import { TranslateService } from "@ngx-translate/core";
import { BaseModel } from "./base.model";
export class BorrowTransactionsModel extends BaseModel {
borrow_id: string;
pe_id: string;
quantity_borrowed: number;
status: string;
returned_date?: string;
constructor(data?: Partial<BorrowTransactionsModel>, translateService?: TranslateService) {
super(data, translateService);
this.borrow_id = data?.borrow_id ?? '';
this.pe_id = data?.pe_id ?? '';
this.quantity_borrowed = data?.quantity_borrowed ?? 0;
this.status = data?.status ?? '';
this.returned_date = data?.returned_date ?? null;
}
}
import { TranslateService } from "@ngx-translate/core";
import { BaseModel } from "./base.model";
export class ProjectEquipmentModel extends BaseModel {
pe_id: string;
project_id: string;
equipment_id?: string;
quantity_in_project: number;
created_at: string;
updated_at: string;
constructor(data?: Partial<ProjectEquipmentModel>, translateService?: TranslateService) {
super(data, translateService);
this.pe_id = data?.pe_id ?? '';
this.project_id = data?.project_id ?? '';
this.equipment_id = data?.equipment_id ?? '';
this.quantity_in_project = data?.quantity_in_project ?? 0;
this.created_at = data?.created_at ?? new Date().toISOString();
this.updated_at = data?.updated_at ?? new Date().toISOString();
}
}
import { TranslateService } from "@ngx-translate/core";
import { BaseModel } from "./base.model";
export class ProjectMemberModel extends BaseModel {
pm_id: string;
user_id: string;
project_id: string;
role_in_project: string;
created_at: string;
updated_at: string;
constructor(data?: Partial<ProjectMemberModel>, translateService?: TranslateService) {
super(data, translateService);
this.pm_id = data?.pm_id ?? '';
this.user_id = data?.user_id ?? '';
this.project_id = data?.project_id ?? '';
this.role_in_project = data?.role_in_project ?? '';
this.created_at = data?.created_at ?? new Date().toISOString();
this.updated_at = data?.updated_at ?? new Date().toISOString();
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { map, tap, switchMap, filter, reduce } from "rxjs/operators";
import { ProjectEquipmentModel } from '../models/project-equipments';
import { BorrowTransactionsModel } from '../models/borrow-transactions';
@Injectable({
providedIn: 'root'
})
export class BorrowTransactionsService {
apiBaseUrl = environment.baseUrl + "/borrow-transactions";
constructor(
private http: HttpClient
) { }
getById(id: string) {
return this.http
.get<BorrowTransactionsModel>(this.apiBaseUrl + "/" + id)
.pipe(map((e) => new BorrowTransactionsModel(e)));
}
getLists() {
return this.http
.get<BorrowTransactionsModel[]>(this.apiBaseUrl)
.pipe(
map((e) => e.map((e) => new BorrowTransactionsModel(e)))
);
}
save(body: BorrowTransactionsModel) {
return this.http.post<{
"message": string,
"user": BorrowTransactionsModel
}>(this.apiBaseUrl, new BorrowTransactionsModel(body));
}
update(body: BorrowTransactionsModel) {
return this.http.put<{
"message": string,
"user": BorrowTransactionsModel
}>(this.apiBaseUrl + "/" + body.borrow_id, new BorrowTransactionsModel(body));
}
delete(body: BorrowTransactionsModel) {
return this.http.delete<{
"message": string,
"user": BorrowTransactionsModel
}>(this.apiBaseUrl + "/" + body.borrow_id);
}
}
}
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { map, tap, switchMap, filter, reduce } from "rxjs/operators";
import { ProjectEquipmentModel } from '../models/project-equipments';
@Injectable({
providedIn: 'root'
})
export class ProjectEquipmentService {
apiBaseUrl = environment.baseUrl + "/project-equipments";
constructor(
private http: HttpClient
) { }
getById(id: string) {
return this.http
.get<ProjectEquipmentModel>(this.apiBaseUrl + "/" + id)
.pipe(map((e) => new ProjectEquipmentModel(e)));
}
getLists() {
return this.http
.get<ProjectEquipmentModel[]>(this.apiBaseUrl)
.pipe(
map((e) => e.map((e) => new ProjectEquipmentModel(e)))
);
}
save(body: ProjectEquipmentModel) {
return this.http.post<{
"message": string,
"user": ProjectEquipmentModel
}>(this.apiBaseUrl, new ProjectEquipmentModel(body));
}
update(body: ProjectEquipmentModel) {
return this.http.put<{
"message": string,
"user": ProjectEquipmentModel
}>(this.apiBaseUrl + "/" + body.equipment_id, new ProjectEquipmentModel(body));
}
delete(body: ProjectEquipmentModel) {
return this.http.delete<{
"message": string,
"user": ProjectEquipmentModel
}>(this.apiBaseUrl + "/" + body.equipment_id);
}
}
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { map, tap, switchMap, filter, reduce } from "rxjs/operators";
import { ProjectMemberModel } from '../models/project-members';
@Injectable({
providedIn: 'root'
})
export class ProjectMemberService {
apiBaseUrl = environment.baseUrl + "/project-members";
constructor(
private http: HttpClient
) { }
getById(id: string) {
return this.http
.get<ProjectMemberModel>(this.apiBaseUrl + "/" + id)
.pipe(map((e) => new ProjectMemberModel(e)));
}
getLists() {
return this.http
.get<ProjectMemberModel[]>(this.apiBaseUrl)
.pipe(
map((e) => e.map((e) => new ProjectMemberModel(e)))
);
}
save(body: ProjectMemberModel) {
return this.http.post<{
"message": string,
"user": ProjectMemberModel
}>(this.apiBaseUrl, new ProjectMemberModel(body));
}
update(body: ProjectMemberModel) {
return this.http.put<{
"message": string,
"user": ProjectMemberModel
}>(this.apiBaseUrl + "/" + body.user_id, new ProjectMemberModel(body));
}
delete(body: ProjectMemberModel) {
return this.http.delete<{
"message": string,
"user": ProjectMemberModel
}>(this.apiBaseUrl + "/" + body.user_id);
}
}
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