func (VS *Server) editItem(c *gin.Context) {
	itemID, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	oldItem, _ := VS.getItemByID(c, itemID, "h_data", "editItem", "oldItem := VS.getItemByID", true)
	newItem, b := VS.getNewItem(c, itemID, oldItem.IDCategory)
	if !b {
		return
	}
	// Check if we are editing another language than the main one
	if VS.isTranslation(c, newItem, newItem.ID) {
		return
	}
	// Audit
	audit := VS.getAuditFromCentral(c, newItem, itemID, Modified)
	modified := VS.dynamicAuditChange(c, newItem, oldItem, audit.ID)

	// Here manually the changes that can not be automatized
	var oldCategory, newCategory string
	oldCategory = VS.getCategoryByID(c, oldItem.IDCategory, "h_data", "editItem", "oldCategory = VS.getCategoryByID").Name
	newCategory = VS.getCategoryByID(c, newItem.IDCategory, "h_data", "editItem", "newCategory = VS.getCategoryByID").Name
	if VS.checkChange(c, audit.ID, "CategoryID", oldCategory, newCategory) {
		modified = true
	}
	if modified {
		if VS.addItemToDatabase(c, newItem, "h_data", "editItem", "VS.addItemToDatabase") {
			VS.updateCategoryItems(c, oldItem.IDCategory, newItem)
			VS.registerAuditAndEvent(c, audit, newItem, newItem.ID)
		} else {
			VS.wrongFeedback(c, "Sorry, there is already one Item with that name in the same category. Please choose another name or category")
		}
	}
	VS.goodFeedback(c, "/data/see-items")
}
// Modifies the Item into the DataBase
Modifies the Item into the DataBase
// Modifies the Item into the DataBase
func (VS *Server) editItem(c *gin.Context) {
	itemID, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	oldItem, _ := VS.getItemByID(c, itemID, "h_data", "editItem", "oldItem := VS.getItemByID", true)
	newItem, b := VS.getNewItem(c, itemID, oldItem.IDCategory)
	if !b {
		return
	}
	if VS.isTranslation(c, newItem, newItem.ID) {
		return
	}
	audit := VS.getAuditFromCentral(c, newItem, itemID, Modified)
	modified := VS.dynamicAuditChange(c, newItem, oldItem, audit.ID)
	var oldCategory, newCategory string
	oldCategory = VS.getCategoryByID(c, oldItem.IDCategory, "h_data", "editItem", "oldCategory = VS.getCategoryByID").Name
	newCategory = VS.getCategoryByID(c, newItem.IDCategory, "h_data", "editItem", "newCategory = VS.getCategoryByID").Name
	if VS.checkChange(c, audit.ID, "CategoryID", oldCategory, newCategory) {
		modified = true
	}
	if modified {
		if VS.addItemToDatabase(c, newItem, "h_data", "editItem", "VS.addItemToDatabase") {
			VS.updateCategoryItems(c, oldItem.IDCategory, newItem)
			VS.registerAuditAndEvent(c, audit, newItem, newItem.ID)
		} else {
			VS.wrongFeedback(c, "Sorry, there is already one Item with that name in the same category. Please choose another name or category")
		}
	}
	VS.goodFeedback(c, "/data/see-items")
}
func ( VS * Server ) editItem ( c * gin . Context ) { itemID , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } oldItem , _ := VS . getItemByID ( c , itemID , " " , " " , " " , true ) newItem , b := VS . getNewItem ( c , itemID , oldItem . IDCategory ) if ! b { return } if VS . isTranslation ( c , newItem , newItem . ID ) { return } audit := VS . getAuditFromCentral ( c , newItem , itemID , Modified ) modified := VS . dynamicAuditChange ( c , newItem , oldItem , audit . ID ) var oldCategory , newCategory string oldCategory = VS . getCategoryByID ( c , oldItem . IDCategory , " " , " " , " " ) . Name newCategory = VS . getCategoryByID ( c , newItem . IDCategory , " " , " " , " " ) . Name if VS . checkChange ( c , audit . ID , " " , oldCategory , newCategory ) { modified = true } if modified { if VS . addItemToDatabase ( c , newItem , " " , " " , " " ) { VS . updateCategoryItems ( c , oldItem . IDCategory , newItem ) VS . registerAuditAndEvent ( c , audit , newItem , newItem . ID ) } else { VS . wrongFeedback ( c , " " ) } } VS . goodFeedback ( c , " " ) }
Modifies the Item into the DataBase
Modifies the Item into the DataBase
// Check if we are editing another language than the main one // Audit // Here manually the changes that can not be automatized