func (VS *Server) addServiceToDatabase(c *gin.Context, s Service, class string, method string, operation string) bool {
	var service []Service
	err := VS.DataBase.Find(&service, bolthold.Where("Name").Eq(s.Name).And("IDVillage").Eq(s.IDVillage))
	VS.checkOperation(c, class, method, operation, err)
	if len(service) != 0 {
		if service[0].ID == s.ID {
			err := VS.DataBase.Upsert(s.ID, s)
			VS.checkOperation(c, class, method, operation, err)
			return true
		}
		return false
	}
	err = VS.DataBase.Upsert(s.ID, s)
	VS.checkOperation(c, class, method, operation, err)
	return true
}
// This method adds (or updates) the Service created to the Database
// Returns true if the operatios was successfully and false if it fails
// We do not allow to have 2 services with he same name
This method adds (or updates) the Service created to the Database
Returns true if the operatios was successfully and false if it fails
We do not allow to have 2 services with he same name
// This method adds ( or updates ) the Service created to the Database // Returns true if the operatios was successfully and false if it fails // We do not allow to have 2 services with he same name
func (VS *Server) addServiceToDatabase(c *gin.Context, s Service, class string, method string, operation string) bool {
	var service []Service
	err := VS.DataBase.Find(&service, bolthold.Where("Name").Eq(s.Name).And("IDVillage").Eq(s.IDVillage))
	VS.checkOperation(c, class, method, operation, err)
	if len(service) != 0 {
		if service[0].ID == s.ID {
			err := VS.DataBase.Upsert(s.ID, s)
			VS.checkOperation(c, class, method, operation, err)
			return true
		}
		return false
	}
	err = VS.DataBase.Upsert(s.ID, s)
	VS.checkOperation(c, class, method, operation, err)
	return true
}
func ( VS * Server ) addServiceToDatabase ( c * gin . Context , s Service , class string , method string , operation string ) bool { var service [ ] Service err := VS . DataBase . Find ( & service , bolthold . Where ( " " ) . Eq ( s . Name ) . And ( " " ) . Eq ( s . IDVillage ) ) VS . checkOperation ( c , class , method , operation , err ) if len ( service ) != 0 { if service [ 0 ] . ID == s . ID { err := VS . DataBase . Upsert ( s . ID , s ) VS . checkOperation ( c , class , method , operation , err ) return true } return false } err = VS . DataBase . Upsert ( s . ID , s ) VS . checkOperation ( c , class , method , operation , err ) return true }
This method adds (or updates) the Service created to the Database
Returns true if the operatios was successfully and false if it fails
We do not allow to have 2 services with he same name
This method adds ( or updates ) the Service created to the Database Returns true if the operatios was successfully and false if it fails We do not allow to have 2 services with he same name