Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset funds endpoint #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

DamirAlkhaov
Copy link

API endpoint to reset a users funds

Feel like it would be a good option to have.

Copy link
Member

@sushiat sushiat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to further expand this to a full account reset here a few things coming to mind:

  • Make sure all aircraft are on the ground at least - no active flights, maintenance (not yet fully added) shouldn't matter
  • Make sure the user isn't the primary owner of an airline, again don't have that yet fully implemented but the airline model has a FounderID. In the long term the airline will have to be transferred to another user or formally dissolved - whatever that will look like. But refuse to do a reset for an active airline founder.
  • Not sure about rented aircraft yet - again not fully implemented. The idea was that you either have to return it or pay for the return to origin.
  • All player owned aircraft get returned to the system, custom stuff like aircraft name get removed and variant aircraft changed back to base version.

Timestamp = DateTime.UtcNow,
UserID = user.Id,
Category = FinancialCategory.None,
Expense = user.PersonalAccountBalance - user.PersonalAccountBalance,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will just set the Expense to 0, just set user.PersonalAccountBalance here

};
await this.db.FinancialRecords.AddAsync(resetRecord);

var saveEx = await this.db.SaveDatabaseChangesAsync(this.logger, "Failed to reset funds");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before saving the changes you also need to actually adjust the user's balance. The financial record above is just the trace record of what happened.

user.PersonalAccountBalance = 0;

/// Damir, 29/11/2023
/// </remarks>
/// <returns>
/// An asynchronous result that yields the account balances.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it yields a status string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants