def put(self, name): if StoreModel.find_by_name(name): return {"message": f"An store with name {name} already exists!"}, 400 store = StoreModel(name) try: store.save_to_db() except: return {"message": "An error occured while creating store!"}, 500 return store.json(), 201
def post(self, name): if StoreModel.find_by_name(name): return {"message":f"A store with the name {name} already exists"}, 400 store = StoreModel(name) try: store.save_to_db() except Exception as e: return {"message":"An error occurred while creating the store."}, 500 return store.json(), 500
def post(self, name): if StoreModel.find_by_name(name): return {"message": "store already exists"} store = StoreModel(name) try: store.save_to_db() except: return {"message": "An error occurred while creating store"}, 500 return store.json(), 201
def post(self, name): if StoreModel.find_by_name(name): return {"Message":"Store is exists"}, 400 store = StoreModel(name) try: store.save_to_db() except: return {"Message":"Store save db error"}, 500 return store.json(), 201
def post(self, name): if StoreModel.find(name): return {"message": "Store '{}' already exists".format(name)}, 400 store = StoreModel(name) try: store.save() except: return { "message": "An error occurred while creating the store" }, 500 return store.json(), 200
def post(self, name): store = StoreModel.find_by_name(name) if store: return { 'message': "a store with the name {}, already exist".format(name) }, 400 store = StoreModel(name) try: store.add_to_db() except: return {'message': 'an error occured while adding store'}, 500 return store.json(), 201
def post(self, name): if StoreModel.find_by_name(name): return { 'message': 'A store with the name {} already exists'.format(name) }, 400 store = StoreModel(name) try: store.save_to_db() except: return {'message': 'An error ocurred while creating the store ):'} return store.json()
def post(self, name): if StoreModel.find_by_name(name): return { 'message': "A store with name '{}' already exists".format(name) }, 404 store = StoreModel(name) try: store.save_to_db() except: return { 'message': 'An error occurred while creating the store.' }, 500 return store.json(), 201
def post(self, name): store = StoreModel.find_name(name) #print('item',item) if store: return { 'message': "the store '{}' already exists".format(name) }, 400 store = StoreModel(name) try: store.save_to_db() except: return { 'message': 'An error occured while creating the store' }, 500 return store.json(), 201