// createOrg creates a new organization
createOrg creates a new organization
// createOrg creates a new organization
func (s *Srv) createOrg(w http.ResponseWriter, r *http.Request) {
	var o org.Org
	err := o.ParseOrg(r)
	if err != nil {
		log.Fatal(err)
	}
	var result org.Org
	err = s.db.Database("podoloff").Collection("orgs").FindOne(context.TODO(), bson.D{primitive.E{Key: "name", Value: o.Name}}).Decode(&result)
	if err != nil {
		if err.Error() == "mongo: no documents in result" {
			_, err = s.db.Database("podoloff").Collection("orgs").InsertOne(context.TODO(), o)
			if err != nil {
				io.WriteString(w, "Unable to add org. Please try again.")
				return
			}
			io.WriteString(w, "Org successfully added!")
			return
		}
	}
	io.WriteString(w, "An organization with that name already exists. Please try another.")
	return
}
func ( s * Srv ) createOrg ( w http . ResponseWriter , r * http . Request ) { var o org . Org err := o . ParseOrg ( r ) if err != nil { log . Fatal ( err ) } var result org . Org err = s . db . Database ( " " ) . Collection ( " " ) . FindOne ( context . TODO ( ) , bson . D { primitive . E { Key : " " , Value : o . Name } } ) . Decode ( & result ) if err != nil { if err . Error ( ) == " " { _ , err = s . db . Database ( " " ) . Collection ( " " ) . InsertOne ( context . TODO ( ) , o ) if err != nil { io . WriteString ( w , " " ) return } io . WriteString ( w , " " ) return } } io . WriteString ( w , " " ) return }
createOrg creates a new organization
createOrg creates a new organization