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
- Initial Check with Copilot: - The copilot is already trained on previous methods. 
- It can suggest solutions but may not fully understand complex tasks. 
 
- 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. 
 
- 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. 
 
- 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. 
 
- 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:
- Check for the Company and Shareholder: - Ensure the company exists and the shareholder is identified. 
 
- Save Changes or Handle Errors: - Save changes to the database or catch any potential errors that may occur. 
 
- 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.