예제 #1
0
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
예제 #2
0
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
예제 #3
0
파일: views.py 프로젝트: shymmq/plu-week5
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)
예제 #4
0
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
예제 #5
0
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
예제 #6
0
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()