creacion de reservas con su codigo unico
This commit is contained in:
parent
9817883235
commit
e31ded9eb9
|
@ -2,6 +2,7 @@ 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export interface User {
|
export interface User {
|
||||||
id: number;
|
userID: number;
|
||||||
discotecaID: number;
|
discotecaID: number;
|
||||||
userType: number;
|
userType: number;
|
||||||
username: string;
|
username: string;
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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({
|
||||||
|
@ -51,6 +52,10 @@ export class ApiService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
creaReserva(reserva: Reservai): Observable<Reservai>{
|
||||||
|
return this.http.post<Reservai>(this.baseUrl+"/reserva", reserva);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 = {
|
||||||
id: 0,
|
userID: 0,
|
||||||
discotecaID: 0,
|
discotecaID: 0,
|
||||||
userType: 0,
|
userType: 0,
|
||||||
username: '',
|
username: '',
|
||||||
|
|
|
@ -27,10 +27,13 @@
|
||||||
</div>
|
</div>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-button (click)="generarCodigo(); openReserva()">
|
<ion-button (click)="openReserva()">
|
||||||
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>
|
||||||
|
|
|
@ -5,8 +5,10 @@ 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 { 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',
|
||||||
|
@ -19,29 +21,58 @@ export class ViewEventoClientePage implements OnInit {
|
||||||
discoteca: DiscotecaI;
|
discoteca: DiscotecaI;
|
||||||
reserva: Reservai;
|
reserva: Reservai;
|
||||||
codigoReserva: string;
|
codigoReserva: string;
|
||||||
|
reservaRealizada: boolean;
|
||||||
|
|
||||||
constructor(private feedService: FeedService, private modalController: ModalController,
|
constructor(private feedService: FeedService, private modalController: ModalController,
|
||||||
private codigoReservaService: CodigoreservaService) { }
|
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(){
|
generarCodigo(){
|
||||||
this.codigoReserva = stringify(this.codigoReservaService.generarAleatorio());
|
return stringify(this.codigoReservaService.generarAleatorio());
|
||||||
console.log(this.codigoReserva);
|
}
|
||||||
|
|
||||||
|
initReserva(){
|
||||||
|
this.reserva = {
|
||||||
|
UserID: this.loginService.user.userID,
|
||||||
|
EventoID: this.evento.id,
|
||||||
|
codigoDescuento: null,
|
||||||
|
codigoUnico: '',
|
||||||
|
codigoUnicoID: null,
|
||||||
|
descuentoPorciento: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openReserva(){
|
openReserva(){
|
||||||
|
this.initReserva();
|
||||||
|
this.reserva.codigoDescuento = (<HTMLInputElement>document.getElementById("codigoDescuento")).value;
|
||||||
|
this.reserva.codigoUnico = this.generarCodigo();
|
||||||
|
this.creaReserva(this.reserva);
|
||||||
|
}
|
||||||
|
|
||||||
|
creaReserva(reserva){
|
||||||
|
this.apiService.creaReserva(reserva)
|
||||||
|
.subscribe(
|
||||||
|
data => {
|
||||||
|
console.log(data);
|
||||||
|
this.reserva = data;
|
||||||
|
this.reservaRealizada = true;
|
||||||
this.modalController.create({
|
this.modalController.create({
|
||||||
component: ReservamodalPage,
|
component: ReservamodalPage,
|
||||||
componentProps : {
|
componentProps : {
|
||||||
codigo: this.codigoReserva
|
codigo: this.reserva.codigoUnico
|
||||||
}
|
}
|
||||||
|
|
||||||
}).then(modal => modal.present());
|
}).then(modal => modal.present());
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue