Exemple #1
0
    def addSample(self, id):
        data = SampleService.parser.parse_args()
        sample = Sample.findSampleById(id)

        if sample:
            return "Sample already exists!"
        else:
            sample = Sample(data["id"], data["date"], data["quality"],
                            data["x_coor"], data["y_coor"], data["date_added"],
                            data["location_id"], data["owner_id"],
                            data["taxon_values"])
            sample.save()
            return sample.json()
Exemple #2
0
    def updateSample(self, id):
        data = SampleService.parser.parse_args()
        sample = Sample.findSampleById(id)

        if sample:
            sample.date = data["date"]
            sample.quality = data["quality"]
            sample.x_coor = data["x_coor"]
            sample.y_coor = data["y_coor"]
            sample.date_added = data["date_added"]
            sample.location_id = data["location_id"]
            sample.owner_id = data["owner_id"]
            sample.taxon_values = data["taxon_values"]
        else:
            sample = Sample(data["id"], data["date"], data["quality"],
                            data["x_coor"], data["y_coor"], data["date_added"],
                            data["location_id"], data["owner_id"],
                            data["taxon_values"])

        sample.save()
        return sample.json()