func (VS *Server) editCategory(c *gin.Context) {
	id, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	oldCat := VS.getCategoryByID(c, id, "h_data", "editCategory", "oldCat := VS.getCategoryByID")
	newCategory, b := VS.getNewCategory(c, id)
	if !b {
		return
	}
	// Check if we are editing another language than the main one
	if VS.isTranslation(c, newCategory, newCategory.ID) {
		return
	}
	newCategory.Items = oldCat.Items

	// Audit
	audit := VS.getAuditFromCentral(c, newCategory, id, Modified)
	modified := VS.dynamicAuditChange(c, newCategory, oldCat, audit.ID)
	oldType := VS.getCategoryTypeByID(c, oldCat.Type, "h_data", "editCategory", "oldType := VS.getCategoryTypeByID").Name
	newType := VS.getCategoryTypeByID(c, newCategory.Type, "h_data", "editCategory", "newType := VS.getCategoryTypeByID").Name
	if VS.checkChange(c, audit.ID, "OnlyRent", strconv.FormatBool(newCategory.IsTrackable), strconv.FormatBool(newCategory.IsTrackable)) {
		modified = true
	}
	if VS.checkChange(c, audit.ID, "Type", oldType, newType) {
		VS.move(basePath+"/local-resources/categories/"+oldType+"/"+oldCat.Name+"/", basePath+"/local-resources/categories/"+newType+"/"+newCategory.Name+"/")
		modified = true
	}
	if VS.checkChange(c, audit.ID, "Name", oldCat.Name, newCategory.Name) {
		VS.move(basePath+"/local-resources/categories/"+oldType+"/"+oldCat.Name+"/", basePath+"/local-resources/categories/"+newType+"/"+newCategory.Name+"/")
		modified = true
	}
	if modified {
		if VS.addCategoryToDatabase(c, newCategory, "h_data", "editCategory", "VS.addCategoryToDatabase") {
			VS.registerAuditAndEvent(c, audit, newCategory, newCategory.ID)
		} else {
			VS.wrongFeedback(c, "Sorry, there is already one Category with that name related with this Type, .Please choose another name or Type")
		}
	}
	VS.goodFeedback(c, "/data/categories")
}
// Modifies the Category information into the DataBase
Modifies the Category information into the DataBase
// Modifies the Category information into the DataBase
func (VS *Server) editCategory(c *gin.Context) {
	id, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	oldCat := VS.getCategoryByID(c, id, "h_data", "editCategory", "oldCat := VS.getCategoryByID")
	newCategory, b := VS.getNewCategory(c, id)
	if !b {
		return
	}
	if VS.isTranslation(c, newCategory, newCategory.ID) {
		return
	}
	newCategory.Items = oldCat.Items
	audit := VS.getAuditFromCentral(c, newCategory, id, Modified)
	modified := VS.dynamicAuditChange(c, newCategory, oldCat, audit.ID)
	oldType := VS.getCategoryTypeByID(c, oldCat.Type, "h_data", "editCategory", "oldType := VS.getCategoryTypeByID").Name
	newType := VS.getCategoryTypeByID(c, newCategory.Type, "h_data", "editCategory", "newType := VS.getCategoryTypeByID").Name
	if VS.checkChange(c, audit.ID, "OnlyRent", strconv.FormatBool(newCategory.IsTrackable), strconv.FormatBool(newCategory.IsTrackable)) {
		modified = true
	}
	if VS.checkChange(c, audit.ID, "Type", oldType, newType) {
		VS.move(basePath+"/local-resources/categories/"+oldType+"/"+oldCat.Name+"/", basePath+"/local-resources/categories/"+newType+"/"+newCategory.Name+"/")
		modified = true
	}
	if VS.checkChange(c, audit.ID, "Name", oldCat.Name, newCategory.Name) {
		VS.move(basePath+"/local-resources/categories/"+oldType+"/"+oldCat.Name+"/", basePath+"/local-resources/categories/"+newType+"/"+newCategory.Name+"/")
		modified = true
	}
	if modified {
		if VS.addCategoryToDatabase(c, newCategory, "h_data", "editCategory", "VS.addCategoryToDatabase") {
			VS.registerAuditAndEvent(c, audit, newCategory, newCategory.ID)
		} else {
			VS.wrongFeedback(c, "Sorry, there is already one Category with that name related with this Type, .Please choose another name or Type")
		}
	}
	VS.goodFeedback(c, "/data/categories")
}
func ( VS * Server ) editCategory ( c * gin . Context ) { id , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } oldCat := VS . getCategoryByID ( c , id , " " , " " , " " ) newCategory , b := VS . getNewCategory ( c , id ) if ! b { return } if VS . isTranslation ( c , newCategory , newCategory . ID ) { return } newCategory . Items = oldCat . Items audit := VS . getAuditFromCentral ( c , newCategory , id , Modified ) modified := VS . dynamicAuditChange ( c , newCategory , oldCat , audit . ID ) oldType := VS . getCategoryTypeByID ( c , oldCat . Type , " " , " " , " " ) . Name newType := VS . getCategoryTypeByID ( c , newCategory . Type , " " , " " , " " ) . Name if VS . checkChange ( c , audit . ID , " " , strconv . FormatBool ( newCategory . IsTrackable ) , strconv . FormatBool ( newCategory . IsTrackable ) ) { modified = true } if VS . checkChange ( c , audit . ID , " " , oldType , newType ) { VS . move ( basePath + " " + oldType + " " + oldCat . Name + " " , basePath + " " + newType + " " + newCategory . Name + " " ) modified = true } if VS . checkChange ( c , audit . ID , " " , oldCat . Name , newCategory . Name ) { VS . move ( basePath + " " + oldType + " " + oldCat . Name + " " , basePath + " " + newType + " " + newCategory . Name + " " ) modified = true } if modified { if VS . addCategoryToDatabase ( c , newCategory , " " , " " , " " ) { VS . registerAuditAndEvent ( c , audit , newCategory , newCategory . ID ) } else { VS . wrongFeedback ( c , " " ) } } VS . goodFeedback ( c , " " ) }
Modifies the Category information into the DataBase
Modifies the Category information into the DataBase
// Check if we are editing another language than the main one // Audit