Sql bug fixed

This commit is contained in:
Eudes Inácio
2021-10-18 07:44:24 +01:00
parent 3ae19356c0
commit 6ed724877e
11 changed files with 389 additions and 127 deletions
+47 -31
View File
@@ -1,12 +1,16 @@
import { Injectable } from '@angular/core';
import { Event, EventToApproveEdit } from '../models/event.model';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Observable, from} from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { UserSession } from '../models/user.model';
import { EventList } from '../models/agenda/AgendaEventList';
import { ChangeProfileService } from './change-profile.service';
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { catchError } from "rxjs/operators";
import { Storage } from '@ionic/storage';
@Injectable({
@@ -30,7 +34,9 @@ export class EventsService {
constructor(
private http: HttpClient,
public user: AuthService,
private changeProfileService: ChangeProfileService)
private changeProfileService: ChangeProfileService,
private offlinemanager: OfflineManagerService,
private storage: Storage)
{
this.loggeduser = this.user.ValidatedUser;
@@ -306,40 +312,50 @@ export class EventsService {
editEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable<Event>
{
let arrayReq = [];
const puturl = environment.apiURL + 'calendar/PutEvent';
if(synchro.connected === false) {
arrayReq.push(event)
return from(this.storage.set('storedreq', arrayReq))
} else {
let params = new HttpParams();
let params = new HttpParams();
params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
params.set('CalendarId', event.CalendarId)
params.set('CalendarName', event.CalendarName)
this.headers['CalendarId'] = event.CalendarId
this.headers['CalendarName'] = event.CalendarName
if(event.CalendarName == 'Oficial'){
if(this.loggeduser.Profile == 'MDGPR'){
this.headers = this.headersMdOficial;
params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
params.set('CalendarId', event.CalendarId)
params.set('CalendarName', event.CalendarName)
this.headers['CalendarId'] = event.CalendarId
this.headers['CalendarName'] = event.CalendarName
if(event.CalendarName == 'Oficial'){
if(this.loggeduser.Profile == 'MDGPR'){
this.headers = this.headersMdOficial;
}
else if(this.loggeduser.Profile == 'PR'){
this.headers = this.headersPrOficial;
}
}
else if(this.loggeduser.Profile == 'PR'){
this.headers = this.headersPrOficial;
else{
if(this.loggeduser.Profile == 'MDGPR'){
this.headers = this.headersMdPessoal;
}
else if(this.loggeduser.Profile == 'PR'){
this.headers = this.headersPrPessoal;
}
}
let options = {
headers: this.headers,
params: params
};
return this.http.put<Event>(`${puturl}`, event, options).pipe(
catchError(err => {
this.offlinemanager.storeRequest(puturl, 'PUT', event);
throw new Error(err);
})
)
}
else{
if(this.loggeduser.Profile == 'MDGPR'){
this.headers = this.headersMdPessoal;
}
else if(this.loggeduser.Profile == 'PR'){
this.headers = this.headersPrPessoal;
}
}
let options = {
headers: this.headers,
params: params
};
return this.http.put<Event>(`${puturl}`, event, options)
}
changeAgenda(body:any){