Even more business logic

In this lesson, we explored updating shareholders and managing share purchases within a company structure using the copilot and repositories. Below is a step-by-step breakdown of the concepts covered.

Concepts Covered

  1. Initial Check with Copilot:

    • The copilot is already trained on previous methods.

    • It can suggest solutions but may not fully understand complex tasks.

  2. Identifying a Company:

    • The first task is to find the company.

    • If the company is not found, close the process; if it is found, proceed to the next steps.

  3. Updating Shareholders:

    • When updating the amount of shares, you also need to update the shareholders' information.

    • This process needs to be done by populating the necessary data.

  4. Shareholders Population and Updating:

    • Once the population is complete, iterate through each shareholder.

    • For each shareholder, check their owned companies and update the shares according to the split factor.

  5. Handling Share Purchase Events:

    • The share purchase event increases the shares for the shareholder and the company ownership.

    • We will not directly track company ownership but will monitor the change in the number of shares.

Implementing Share Purchase Event

Key Steps:

  1. Check for the Company and Shareholder:

    • Ensure the company exists and the shareholder is identified.

  2. Save Changes or Handle Errors:

    • Save changes to the database or catch any potential errors that may occur.

  3. Increase Shareholder's Shares:

    • Locate the shareholder and identify the company for which stocks are being purchased.

    • Verify if the company exists in the shareholder's owned companies list.

    • Increase the number of shares according to the payload provided.