myexam.service.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { Injectable } from '@angular/core';
  2. import { Http } from '@angular/http';
  3. import { AppConfig } from '../../app.config';
  4. import { ResultMessage } from '../../../viewmodel/result';
  5. import { ServiceCommon } from "../service.common";
  6. import {RefundView} from "../../../viewmodel/myexam/RefundView";
  7. import 'rxjs/add/operator/toPromise';
  8. @Injectable()
  9. export class MyexamService {
  10. constructor(private http: Http) { }
  11. getMyexamListView(count: number): Promise<ResultMessage> {
  12. let url: string = AppConfig.getServiceUrl();
  13. url += "MyexamServices/MyexamListView";
  14. return this.http.post(url, JSON.stringify({
  15. userID: localStorage.userID,
  16. pageIndex: 0,
  17. pageSize: count
  18. }), {headers: ServiceCommon.getHeader()})
  19. .toPromise()
  20. .then(res => {
  21. return {
  22. isSuccess: true,
  23. message: "",
  24. data: res.json().rows
  25. } as ResultMessage;
  26. })
  27. .catch(ServiceCommon.serviceErrorHandler);
  28. }
  29. canPay(examinationRegistrationID:string): Promise<ResultMessage> {
  30. let url: string = AppConfig.getServiceUrl();
  31. url += "ExamineApply/CanPay";
  32. return this.http.post(url, JSON.stringify({
  33. examinationRegistrationID: examinationRegistrationID
  34. }), {headers: ServiceCommon.getHeader()})
  35. .toPromise()
  36. .then(res => {
  37. let result = res.json();
  38. return {
  39. isSuccess: result.IsSuccess,
  40. message: result.Message,
  41. data: null
  42. } as ResultMessage;
  43. })
  44. .catch(ServiceCommon.serviceErrorHandler);
  45. }
  46. cancel(ExaminationRegistrationID:string): Promise<ResultMessage>{
  47. let url: string = AppConfig.getServiceUrl();
  48. url += "MyexamServices/Cancel";
  49. return this.http.post(url, JSON.stringify({ExaminationRegistrationID:ExaminationRegistrationID}), {headers: ServiceCommon.getHeader()})
  50. .toPromise()
  51. .then(res => {
  52. return res.json() as ResultMessage;
  53. })
  54. .catch(ServiceCommon.serviceErrorHandler);
  55. }
  56. messageSubmit(ExaminationRegistrationID:string,refundView:RefundView): Promise<ResultMessage>{
  57. let url: string = AppConfig.getServiceUrl();
  58. url += "MyexamServices/CancelApply";
  59. return this.http.post(url, JSON.stringify({ExaminationRegistrationID:ExaminationRegistrationID,RefundView:refundView}), {headers: ServiceCommon.getHeader()})
  60. .toPromise()
  61. .then(res => {
  62. return res.json() as ResultMessage;
  63. })
  64. .catch(ServiceCommon.serviceErrorHandler);
  65. }
  66. }