Add vbs database
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
3b1e3acf56
commit
36efe24e42
|
|
@ -27,6 +27,7 @@ export class VbsPageComponent implements OnInit {
|
||||||
constructor(private formBuilder: FormBuilder, private matDialog: MatDialog, private emailService: EmailService, private scroller: ViewportScroller) {
|
constructor(private formBuilder: FormBuilder, private matDialog: MatDialog, private emailService: EmailService, private scroller: ViewportScroller) {
|
||||||
//this.setupForm();
|
//this.setupForm();
|
||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
|
year: [2026, []],
|
||||||
firstName: ['', [Validators.required]],
|
firstName: ['', [Validators.required]],
|
||||||
lastName: ['', [Validators.required]],
|
lastName: ['', [Validators.required]],
|
||||||
grade: ['', [Validators.required]],
|
grade: ['', [Validators.required]],
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
var connection = require("./connection");
|
||||||
|
var dbVbs = this;
|
||||||
|
|
||||||
|
exports.insertVBS = function(year, email, firstName, lastName, data, callback){
|
||||||
|
connection.query("INSERT INTO VBS (Year,Email,FirstName,LastName,Data) VALUES(?,?,?,?,?)",[year, email, firstName, lastName, data],function(error,result){
|
||||||
|
if (error){
|
||||||
|
console.log(error);
|
||||||
|
callback(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbEvents.getEvent(result.insertId,function(error,event){
|
||||||
|
if (error){
|
||||||
|
callback(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(null,event);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
const nodemailer = require('nodemailer');
|
const nodemailer = require('nodemailer');
|
||||||
|
var dbVbs = require('../../database/vbs');
|
||||||
|
|
||||||
let transporter = nodemailer.createTransport({
|
let transporter = nodemailer.createTransport({
|
||||||
host: 'smtp.ionos.com',
|
host: 'smtp.ionos.com',
|
||||||
|
|
@ -44,9 +45,12 @@ router.post("/", function(req,res){
|
||||||
console.log(error);
|
console.log(error);
|
||||||
res.status(400).json({"status":400,"message":"There was an error","error":error.response});
|
res.status(400).json({"status":400,"message":"There was an error","error":error.response});
|
||||||
} else {
|
} else {
|
||||||
transporter.sendMail(mailOptions2, (error, into) => {
|
dbVbs.insertVBS(req.body.year, req.body.parentEmail, req.body.firstName, req.body.lastName, req.body,function(error,vbs){
|
||||||
res.status(200).json({"status":200,"message":"Success"});
|
transporter.sendMail(mailOptions2, (error, into) => {
|
||||||
});
|
res.status(200).json({"status":200,"message":"Success"});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue