Compare commits

..

No commits in common. "e31ded9eb92ddf0643595440bb7ab18eacfc9c9e" and "024f768da9e8f033f2eecedf36148669aaa0f93d" have entirely different histories.

10 changed files with 9 additions and 108 deletions

View File

@ -2,7 +2,6 @@ export interface Reservai {
UserID: number, UserID: number,
EventoID: number, EventoID: number,
codigoDescuento: string, codigoDescuento: string,
codigoUnico: string,
codigoUnicoID: number, codigoUnicoID: number,
descuentoPorciento: number descuentoPorciento: number
} }

View File

@ -1,5 +1,5 @@
export interface User { export interface User {
userID: number; id: number;
discotecaID: number; discotecaID: number;
userType: number; userType: number;
username: string; username: string;

View File

@ -5,5 +5,5 @@
</ion-header> </ion-header>
<ion-content> <ion-content>
{{codigoReserva}}
</ion-content> </ion-content>

View File

@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NavParams } from '@ionic/angular';
@Component({ @Component({
selector: 'app-reservamodal', selector: 'app-reservamodal',
@ -8,11 +7,9 @@ import { NavParams } from '@ionic/angular';
}) })
export class ReservamodalPage implements OnInit { export class ReservamodalPage implements OnInit {
codigoReserva: string; constructor() { }
constructor(private navParams: NavParams) { }
ngOnInit() { ngOnInit() {
this.codigoReserva = this.navParams.get('codigo');
} }
} }

View File

@ -7,7 +7,6 @@ import { Discoteca } from '../discoteca';
import { UserLogin } from '../interfaces/user-login'; import { UserLogin } from '../interfaces/user-login';
import { DiscotecaI } from '../interfaces/discoteca-i'; import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { Reservai } from '../interfaces/reservai';
@Injectable({ @Injectable({
@ -52,10 +51,6 @@ export class ApiService {
} }
creaReserva(reserva: Reservai): Observable<Reservai>{
return this.http.post<Reservai>(this.baseUrl+"/reserva", reserva);
}

View File

@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { CodigoreservaService } from './codigoreserva.service';
describe('CodigoreservaService', () => {
let service: CodigoreservaService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CodigoreservaService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -1,27 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CodigoreservaService {
codigo: string;
length: number;
constructor() {
}
generarAleatorio(){
this.length = 7;
var result = [];
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < this.length; i++ ) {
result.push(characters.charAt(Math.floor(Math.random() *
charactersLength)));
}
return result.join("");
}
}

View File

@ -17,7 +17,7 @@ export class LoginService {
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) { constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) {
this.user = { this.user = {
userID: 0, id: 0,
discotecaID: 0, discotecaID: 0,
userType: 0, userType: 0,
username: '', username: '',

View File

@ -31,9 +31,6 @@
Reserva Reserva
</ion-button> </ion-button>
</ion-row> </ion-row>
<ion-row>
<span>Código de descuento: </span><input type="text" id="codigoDescuento">
</ion-row>
</div> </div>
</ion-grid> </ion-grid>
</ion-content> </ion-content>

View File

@ -1,14 +1,10 @@
import { stringify } from '@angular/compiler/src/util';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular'; import { ModalController } from '@ionic/angular';
import { DiscotecaI } from '../interfaces/discoteca-i'; import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { Reservai } from '../interfaces/reservai'; import { Reservai } from '../interfaces/reservai';
import { ReservamodalPage } from '../reservamodal/reservamodal.page'; import { ReservamodalPage } from '../reservamodal/reservamodal.page';
import { ApiService } from '../services/api.service';
import { CodigoreservaService } from '../services/codigoreserva.service';
import { FeedService } from '../services/feed.service'; import { FeedService } from '../services/feed.service';
import { LoginService } from '../services/login.service';
@Component({ @Component({
selector: 'app-view-evento-cliente', selector: 'app-view-evento-cliente',
@ -20,59 +16,19 @@ export class ViewEventoClientePage implements OnInit {
evento: Eventoi; evento: Eventoi;
discoteca: DiscotecaI; discoteca: DiscotecaI;
reserva: Reservai; reserva: Reservai;
codigoReserva: string; constructor(private feedService: FeedService, private modalController: ModalController) { }
reservaRealizada: boolean;
constructor(private feedService: FeedService, private modalController: ModalController,
private codigoReservaService: CodigoreservaService, private loginService: LoginService, private apiService: ApiService) { }
ngOnInit() { ngOnInit() {
this.reservaRealizada = false;
this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex); this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex);
this.discoteca = this.feedService.discotecaEvento; this.discoteca = this.feedService.discotecaEvento;
} }
generarCodigo(){
return stringify(this.codigoReservaService.generarAleatorio());
}
initReserva(){
this.reserva = {
UserID: this.loginService.user.userID,
EventoID: this.evento.id,
codigoDescuento: null,
codigoUnico: '',
codigoUnicoID: null,
descuentoPorciento: null
}
}
openReserva(){ openReserva(){
this.initReserva(); this.modalController.create({
this.reserva.codigoDescuento = (<HTMLInputElement>document.getElementById("codigoDescuento")).value; component: ReservamodalPage,
this.reserva.codigoUnico = this.generarCodigo();
this.creaReserva(this.reserva); }).then(modal => modal.present());
}
creaReserva(reserva){
this.apiService.creaReserva(reserva)
.subscribe(
data => {
console.log(data);
this.reserva = data;
this.reservaRealizada = true;
this.modalController.create({
component: ReservamodalPage,
componentProps : {
codigo: this.reserva.codigoUnico
}
}).then(modal => modal.present());
},
error => {
console.log(error);
}
)
} }
} }