Browse Source

Bug fix update itemext

pull/1/head
Georg Spar 1 year ago
parent
commit
026f3684c4
  1. 34
      wdm.go

34
wdm.go

@ -834,8 +834,8 @@ func getItemExtHandler(writer http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodOptions { if req.Method == http.MethodOptions {
return return
} }
itemBId, _ := strconv.ParseUint(mux.Vars(req)["id"], 10, 0) itemExtId, _ := strconv.ParseUint(mux.Vars(req)["id"], 10, 0)
res, err := GetItemB(uint64(itemBId)) res, err := GetItemExt(uint64(itemExtId))
if err != nil { if err != nil {
log.Fatal("Error: Typ can't be shown ", err) log.Fatal("Error: Typ can't be shown ", err)
writer.WriteHeader(http.StatusInternalServerError) writer.WriteHeader(http.StatusInternalServerError)
@ -862,18 +862,18 @@ func updateItemExtHandler(writer http.ResponseWriter, req *http.Request) {
writer.WriteHeader(http.StatusBadRequest) writer.WriteHeader(http.StatusBadRequest)
return return
} }
var itemB Itemb var itemExt ItemExt
if req.Form["bezeichnung"] != nil { if req.Form["genehmigt"] != nil {
itemB.Bezeichnung = req.FormValue("bezeichnung") itemExt.Zuhause, _ = strconv.ParseBool(req.FormValue("zuhause"))
itemB.Kurzbeschreibung = req.FormValue("kurzbeschreibung") itemExt.Draussen, _ = strconv.ParseBool(req.FormValue("draussen"))
itemB.Material = req.FormValue("material") itemExt.Genehmigt, _ = strconv.ParseBool(req.FormValue("genehmigt"))
itemB.Groesse = req.FormValue("groesse") itemExt.Bemerkung = req.FormValue("bemerkung")
itemB.Farbe = req.FormValue("farbe") itetyp, _ := strconv.ParseUint(req.FormValue("bewertung"), 10, 0)
itbtyp, _ := strconv.ParseUint(req.FormValue("typid"), 10, 0) itemExt.Bewertung = int(itetyp)
itemB.Type.Id = uint(itbtyp) itemExt.Favorit, _ = strconv.ParseBool(req.FormValue("abmessungenid"))
itemB.Abmessungen.Id, _ = strconv.ParseUint(req.FormValue("abmessungenid"), 10, 0) itemExt.Frontview.Id, _ = strconv.ParseUint(req.FormValue("frontviewid"), 10, 0)
itemB.Frontview.Id, _ = strconv.ParseUint(req.FormValue("frontviewid"), 10, 0) itemExt.ItemB.Id, _ = strconv.ParseUint(req.FormValue("itembid"), 10, 0)
itemB.Id, _ = strconv.ParseUint(req.FormValue("id"), 10, 0) itemExt.Id, _ = strconv.ParseUint(req.FormValue("id"), 10, 0)
for formKey, formValue := range req.Form { for formKey, formValue := range req.Form {
log.WithFields(log.Fields{formKey: formValue}).Info("parsing from Form: ") log.WithFields(log.Fields{formKey: formValue}).Info("parsing from Form: ")
} }
@ -887,9 +887,9 @@ func updateItemExtHandler(writer http.ResponseWriter, req *http.Request) {
json.Unmarshal(body, &itemB) json.Unmarshal(body, &itemB)
} }
log.Println("Name = ", itemB.Bezeichnung) log.Println("ID = ", itemExt.Id)
log.Info("updating Typ", itemB.Bezeichnung) log.Info("updating ItemExt", itemExt.Id)
res, err := UpdateItemB(itemB) res, err := UpdateItemExt(itemExt)
if err != nil { if err != nil {
writer.WriteHeader(http.StatusInternalServerError) writer.WriteHeader(http.StatusInternalServerError)
} }

Loading…
Cancel
Save