import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BaseService } from '../../base/base-service';
import {environment} from '../../../../environments/environment';

@Injectable({
    providedIn: 'root'
})
export class TestingInformationService extends BaseService {
    info;
    constructor(
        public http: HttpClient
    ) {
        super('/v1/information/testing_informations', http)
     }
    getDatatype(){
        return this.http.get(`${environment.enrollmentApi}/api/v1/enrollment/candidate_types`);
    }

    getAlltoday(){
        return this.http.get(`${this.fullUrl}_compare_with_today`);
    }

    getMaintrue(){
        return this.http.get(`${this.fullUrl}?is_main=true`);
    }

    getMaintrueAndTestInforUid(uid){
        return this.http.get(`${this.fullUrl}?is_main=true&testing_information_uid=${uid}`);
    }

    getMaintrueANDOpenNull(){
        return this.http.get(`${this.prefix}/v1/information/testing_information_is_open`);
    }

    getOpenandMaintrue(){
        return this.http.get(`${this.fullUrl}?is_main=true&is_open=true`);
    }

    getCloseandMaintrue(){
        return this.http.get(`${this.fullUrl}?is_main=true&is_open=null`);
    }

    getisOpenNullandMaintrue(){
        return this.http.get(`${this.fullUrl}?is_main=true&is_open=null`);
    }

    searchisOpenNullFalseandMaintrue(data){
        return this.http.get(`${this.fullUrl}${data}?is_main=true&is_open=null`);
    }

    getForCountSeat(){
        return this.http.get(`${this.prefix}/v1/information/testing_information_for_chk_statuss`);
    }

    getPage(query){
        return this.http.get(`${this.prefix}/v1/information/testing_information_for_chk_status_get_paged/${query}`);
    }

    getSearchForCountSeat(query){
        return this.http.get(`${this.prefix}/v1/information/testing_information_for_chk_statuss/${query}`);
    }

    getMaintrueandCounte(){
        return this.http.get(`${this.fullUrl}?is_main=true&is_counter=true`);
    }

    getMainfalse(data?){
        return this.http.get(`${this.fullUrl}?is_main=false`);
    }

    searchFalse(data){
        return this.http.get(`${this.fullUrl}${data}&is_main=false`);
    }

    getCheckmaintrue(mainID){
        return this.http.get(`${this.fullUrl}?main_testing_information_uid=${mainID}`);
    }

    querytypeofexaminee(typeofexam){
        return this.http.get(`${this.fullUrl}_compare_with_today?type_of_examinee=${typeofexam}&is_counter=true`);
    }

    querytypeofexamineeUid(uid){
        return this.http.get(`${this.fullUrl}_compare_with_today?candidate_type_uid=${uid}&is_counter=true&is_open=true`);
    }

    querytypeofexamineeiscouter(typeofexam){
        return this.http.get(`${this.fullUrl}_compare_with_today?type_of_examinee=${typeofexam}`);
    }

    approveExam(TestingInforUid , periodId , date){
        return this.http.post(`${this.prefix}/v1/information/release_exam/${TestingInforUid}/${periodId}/${date}`, null);
    }

    approveExamAPIstore(TestingInforUid , periodId , date){
        return this.http.post(`${environment.storeApi}/api/tests/release_exam_tests/${periodId}/${TestingInforUid}/${date}`, null);
    }

    getAllForSeat(){
        return this.http.get(`${this.prefix}/v1/information/testing_information_for_generate_seat`);
    }

    searchForSeat(query: string) {
        return this.http.get(`${this.prefix}/v1/information/testing_information_for_generate_seat${query}`)
    }

    checkandopentest(TestingInforUid){
        return this.http.post(`${this.prefix}/v1/information/open_testing_information/${TestingInforUid}`, null);
    }

    checkBeforeSync(TestingInforUid){
        return this.http.post(`${this.prefix}/v1/information/check_before_sync/${TestingInforUid}`, null);

    }

    checkandclosetest(TestingInforUid){
        return this.http.post(`${this.prefix}/v1/information/close_testing_information/${TestingInforUid}`, null);
    }

    getSummarySubject(TestingInforUid, date){
        return this.http.get(`${this.prefix}/v1/information/summary_by_subject/${TestingInforUid}/${date}`);
    }
}
