Rename the methods
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { forkJoin, Observable, of } from "rxjs";
|
||||
import { forkJoin, Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
|
||||
import { JumpResp, JumpReq, Jump } from "../models/jump";
|
||||
@@ -32,28 +32,26 @@ export class JumpService extends BaseService {
|
||||
super();
|
||||
}
|
||||
|
||||
public GetListOfJumps(): Observable<Array<Jump>> {
|
||||
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
|
||||
{ headers: this.headers })
|
||||
.pipe(map((response) => {
|
||||
return this.MapWithDataInCache(response);
|
||||
}));
|
||||
public getListOfJumps(): Observable<Array<Jump>> {
|
||||
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, { headers: this.headers })
|
||||
.pipe(map((response) => {
|
||||
return this.mapWithDataInCache(response);
|
||||
}));
|
||||
}
|
||||
|
||||
public GetJumps(beginIndex: number, endIndex: number): Observable<JumpList> {
|
||||
return this.http.get<JumpListResp>(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`,
|
||||
{ headers: this.headers })
|
||||
.pipe(map((response) => {
|
||||
let result: JumpList = {
|
||||
rows: this.MapWithDataInCache(response.rows),
|
||||
count: response.count
|
||||
};
|
||||
public getJumps(beginIndex: number, endIndex: number): Observable<JumpList> {
|
||||
return this.http.get<JumpListResp>(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`, { headers: this.headers })
|
||||
.pipe(map((response) => {
|
||||
let result: JumpList = {
|
||||
rows: this.mapWithDataInCache(response.rows),
|
||||
count: response.count
|
||||
};
|
||||
|
||||
return new JumpList(result);
|
||||
}));
|
||||
return new JumpList(result);
|
||||
}));
|
||||
}
|
||||
|
||||
public AddListOfJump(selectedJumpType: number,
|
||||
public addListOfJump(selectedJumpType: number,
|
||||
selectedAircraft: number,
|
||||
selectedDz: number,
|
||||
selectedRig: number,
|
||||
@@ -66,11 +64,11 @@ export class JumpService extends BaseService {
|
||||
notes: string,
|
||||
isSpecial: boolean): Observable<any[]> {
|
||||
this.callsToAdd = new Array<Observable<any>>();
|
||||
const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1;
|
||||
const diffInDays = this.dateService.diffBetweenDates(beginDate, endDate) + 1;
|
||||
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
|
||||
|
||||
for (let i = 1; beginDate.getTime() < endDate.getTime(); i++) {
|
||||
this.AddJumps(selectedJumpType,
|
||||
this.addJumps(selectedJumpType,
|
||||
selectedAircraft,
|
||||
selectedDz,
|
||||
selectedRig,
|
||||
@@ -82,12 +80,12 @@ export class JumpService extends BaseService {
|
||||
notes,
|
||||
isSpecial);
|
||||
|
||||
beginDate = this.dateService.AddDays(beginDate, 1);
|
||||
beginDate = this.dateService.addDays(beginDate, 1);
|
||||
}
|
||||
|
||||
const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1);
|
||||
|
||||
this.AddJumps(selectedJumpType,
|
||||
this.addJumps(selectedJumpType,
|
||||
selectedAircraft,
|
||||
selectedDz,
|
||||
selectedRig,
|
||||
@@ -102,16 +100,16 @@ export class JumpService extends BaseService {
|
||||
return forkJoin(this.callsToAdd);
|
||||
}
|
||||
|
||||
public DeleteJump(item: Jump) {
|
||||
public deleteJump(item: Jump) {
|
||||
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
|
||||
{ headers: this.headers, })
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
public UpdateJump(id: number,
|
||||
isSpecial: boolean,
|
||||
withCutaway: boolean,
|
||||
notes: string) {
|
||||
public updateJump(id: number,
|
||||
isSpecial: boolean,
|
||||
withCutaway: boolean,
|
||||
notes: string) {
|
||||
const jumpData = {
|
||||
id: id,
|
||||
isSpecial: isSpecial,
|
||||
@@ -125,7 +123,7 @@ export class JumpService extends BaseService {
|
||||
{ headers: this.headers, });
|
||||
}
|
||||
|
||||
private AddJumps(selectedJumpType: number,
|
||||
private addJumps(selectedJumpType: number,
|
||||
selectedAircraft: number,
|
||||
selectedDz: number,
|
||||
selectedRig: number,
|
||||
@@ -157,7 +155,7 @@ export class JumpService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
private MapWithDataInCache(apiResp: Array<JumpResp>): Array<Jump> {
|
||||
private mapWithDataInCache(apiResp: Array<JumpResp>): Array<Jump> {
|
||||
let allDropzones: Array<DropZoneResp>;
|
||||
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });
|
||||
let allAircrafts: Array<AircraftResp>;
|
||||
|
||||
Reference in New Issue
Block a user