async def update_supplier(request: schemas.SupplierRequest, supplier_id: int, db: Session = Depends(get_db)): db_supplier = crud.get_supplier_by_id(db, supplier_id) if db_supplier is None: raise HTTPException(status_code=404, detail="Supplier not found") crud.update_supplier(db, supplier_id, request) updated_supplier = crud.get_supplier_by_id(db, supplier_id) return updated_supplier
async def update_supplier(supplier_id: PositiveInt, supplier: dict, db: Session = Depends(get_db)): db_supplier = crud.get_supplier(db, supplier_id) if db_supplier is None: raise HTTPException(status_code=404, detail="Supplier not found") else: if supplier != {}: crud.update_supplier(db, supplier, supplier_id) db.commit() db_supplier = crud.get_supplier(db, supplier_id) return db_supplier
async def update_supplier(supplier_id, new_props: schemas.SupplierUpdate, db: Session = Depends(get_db)): db_supplier = crud.get_supplier(db, supplier_id) if db_supplier is None: raise HTTPException(status_code=404, detail="Supplier not found") return crud.update_supplier(db, supplier_id, new_props)
async def update_supplier(id: int, supplier_update: schemas.SupplierUpdate, db: Session = Depends(database.get_db)): updated_supplier = crud.update_supplier(db, id, supplier_update) if not updated_supplier: raise HTTPException(status_code=404) return updated_supplier
async def update_supplier(supplier_id: PositiveInt, supplier: schemas.SupplierUpdate, db: Session = Depends(get_db)): updated_supplier = crud.update_supplier(db, supplier_id, supplier) if not updated_supplier: raise HTTPException(status_code=404, detail="Supplier not found") return updated_supplier
def change_supplier(db: Session = Depends(get_db), supplier_id: int = Path(..., alias='id'), supplier: schemas.SupplierUpdate = ...): """Update supplier with given id using data from request body and return updated object.""" record = crud.update_supplier(db, supplier_id, supplier) if not record: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail='Supplier not found') return record.export()