Broker System for Supercredit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8KB

  1. import {HttpClient} from '@angular/common/http';
  2. import {AuthService} from './auth.service';
  3. import {Observable} from 'rxjs';
  4. import {LoanModel} from '../models/loan.model';
  5. import {Injectable} from '@angular/core';
  6. import {RewardModel} from '../models/reward.model';
  7. import {ClonerService} from './clone.service';
  8. import {PayInModel} from '../models/pay-in.model';
  9. @Injectable()
  10. export class LoanSingleService {
  11. constructor(private http: HttpClient, private auth: AuthService, private dcs: ClonerService ){ }
  12. getLoan(loanId: string): Observable<LoanModel> {
  13. return this.http.get<LoanModel>(this.auth.getUrl('loan/' + loanId));
  14. }
  15. public updateBasicInfo(loan: LoanModel): Observable<any>{
  16. return this.http.post(this.auth.getUrl('loan/basic/' + loan.Id), loan.cloneForJson());
  17. }
  18. public photoUrl(peopleId: string): string{
  19. const url = this.auth.getUrl('avatar/') + peopleId;
  20. return 'url("' + url + '")';
  21. }
  22. public saveReward(reward: RewardModel, isNew: boolean ): Observable<RewardModel> {
  23. return this.http.post<RewardModel>(this.auth.getUrl('reward/'), reward);
  24. }
  25. public removeReward(reward: RewardModel): void {
  26. this.http.delete<RewardModel>(this.auth.getUrl('reward/' + reward.Id)).subscribe(
  27. resp => {
  28. console.log(resp);
  29. }
  30. );
  31. }
  32. public savePayIn(payIn: PayInModel, isNew: boolean): Observable<PayInModel> {
  33. return this.http.post<PayInModel>(this.auth.getUrl('payIn/'), payIn);
  34. }
  35. public removePayIn(id: number): void {
  36. this.http.delete<PayInModel>(this.auth.getUrl('payIn/' + id)).subscribe(
  37. resp => {
  38. console.log(resp);
  39. }
  40. );
  41. }
  42. // delete means more than remove, it removes relevant data too
  43. public deleteLoan(id: string): Observable<string> {
  44. return this.http.delete<string>(this.auth.getUrl('loan/' + id));
  45. }
  46. }