Sprechstunden löschen
This commit is contained in:
parent
78af58a51d
commit
2ce7a1fae1
15 changed files with 100 additions and 34 deletions
29
controllers/deleteOfficeHourHandler.go
Normal file
29
controllers/deleteOfficeHourHandler.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
// deleteOfficeHourHandler
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"sprechstundentool/models"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (b *BaseHandler) DeleteOfficeHourHandler(w http.ResponseWriter, req *http.Request) {
|
||||
if req.FormValue("id") != "" {
|
||||
id, err := strconv.Atoi(req.FormValue("id"))
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
officeHour, err := b.officeHourRepo.FindById(id)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
_, err = b.requestRepo.Add(officeHour, models.RequestDelete)
|
||||
tmpl, _ := template.New("deleteSuccess.html").ParseFiles("templates/deleteSuccess.html")
|
||||
tmpl.Execute(w, struct{}{})
|
||||
} else {
|
||||
officeHours, _ := b.officeHourRepo.GetAll(true)
|
||||
timetable, slots := GetTimetable(officeHours)
|
||||
b.writeTimetablePage(w, req, printTimetable(timetable, slots, true))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue