I'm studying C # and I'm having some doubts .. The project I'm doing is a fictitious gallery system that registers Artists, Trustees, and Art Pieces.
I have created the abstract class "Persons" that contains the first and last name of the person, and two classes (Artist and Curator) that inherit from "Persons" and which have the variables artistID and curatorID respectively and the appropriate constructors. / p>
I created the ArtPiece class, which stores all artwork information and after that, I created three classes / collections (Artists, Curators and Pieces) inheriting from IEnumerable and implementing two methods.
Class / Collection Artists:
List<Artist> artists = new List<Artist>();
public void Add(Artist artist) {artists.Add(artist);}
IEnumerator IEnumerable.GetEnumerator() {return artists.GetEnumerator();}
Class / Curators Collection:
List<Curator> curators = new List<Curator>();
public void Add(Curator curator) {curators.Add(curator);}
IEnumerator IEnumerable.GetEnumerator() {return curators.GetEnumerator();}
Class / Pieces Collection:
List<ArtPiece> pieces = new List<ArtPiece>();
public void Add(ArtPiece piece) {pieces.Add(piece);}
IEnumerator IEnumerable.GetEnumerator() {return pieces.GetEnumerator();}
In the Gallery class, I instantiated the collections as follows:
Artists artist = new Artists();
Curators curators = new Curators();
Pieces artPieces = new Pieces();
And now, still in the Gallery Class, I need to make the method for the sale of a piece of art, where the status of the piece will be updated and the curator who is associated with curatorID will be added to it. the only two parameters that this method receives is the price at which the part was sold and its ID and returning true if successfully sold, or false if the operation is not performed, it looks like this:
public bool SellPiece(string pieceID, double price) {}
How can I, by the ID of the part, change the status of the part to be sold, take the information from the healer ID associated with it, and by the healer ID add the appropriate commission to it?
I tried to use
var piece = artPieces.Where
To get the ArtPiece object that has the ID passed as a parameter, but neither does the .Where option appear to use it.
I tried to leave the question as "wrapped up" as possible.