Esempio n. 1
0
async def add_money_to_account(income: float,
                               db: Session = Depends(get_db),
                               current_user: schemas.User = Depends(
                                   hs.get_current_user)):
    add_credits_to_the_wallet(db, current_user.id, income)
    my_user = crud.get_user(db, current_user.id)
    print(my_user.wallet)
Esempio n. 2
0
def substract_credits_from_the_wallet(database, user_id: int,
                                      amount_of_money: float):
    user = crud.get_user(database, user_id)
    if (user.wallet < amount_of_money):
        return False
    new_value = user.wallet - amount_of_money
    return crud.update_wallet(database, user_id, new_value)
Esempio n. 3
0
async def check_myself(db: Session = Depends(get_db),
                       current_user: schemas.User = Depends(
                           hs.get_current_user)):
    if current_user is not None:
        return crud.get_user(db, current_user.id)
Esempio n. 4
0
def check_user_wallet(database, user_id: int, money: float):
    user = crud.get_user(database, user_id)
    return user.wallet - money
Esempio n. 5
0
def add_credits_to_the_wallet(database, user_id: int, amount_of_money: float):
    user = crud.get_user(database, user_id)
    new_value = user.wallet + amount_of_money
    return crud.update_wallet(database, user_id, new_value)