/// <summary> /// Get Artist object from XElement node /// </summary> /// <param name="node"></param> /// <remarks> /// Takes an XElement node of eventItem and extracts the data for that events /// Artist element. Checks to see if that Artist already exists, if yes than return, /// if no then create a new Artist from data in node. /// </remarks> /// <returns></returns> public static Artist GetArtistFromNode(System.Xml.Linq.XElement node) { if (node == null || node.Element(Constants.Artist.artistIDElement) == null) { return(null); } int artistId = 0; var artistElement = node.GetXElement(Constants.Artist.artistIDElement); int.TryParse(artistElement, out artistId); Artist artist = Artist.GetArtistByID(artistId); if (!artist.IsNew) { return(artist); } int artistStatusId, artistStatus; string artistFirstName = (string)node.GetXElement(Constants.Artist.artistFirstNameElement); string artistLastName = (string)node.GetXElement(Constants.Artist.artistLastNameElement); string artistName4 = (string)node.GetXElement(Constants.Artist.artistName4Element); string artistName5 = (string)node.GetXElement(Constants.Artist.artistName5Element); string artistNote = (string)node.GetXElement(Constants.Artist.artistNoteElement); int.TryParse((string)node.GetXElement(Constants.Artist.artistStatusElement), out artistStatus); int.TryParse((string)node.GetXElement(Constants.Artist.artistStatusIDElement), out artistStatusId); artist = SetArtistData(artist, artistId, artistFirstName, artistLastName, artistName4, artistName5, artistNote, artistStatus, artistStatusId); return(artist); }
private static WorkArtist BuildWorkArtist(System.Xml.Linq.XElement node, int workArtistID, WorkArtist workArtist) { Artist artist = Artist.GetArtistByID(workArtistID); if (artist.IsNew) { artist.ArtistID = workArtistID; artist.ArtistLastName = (string)node.GetXElement(Constants.WorkArtist.workArtistLastNameElement); artist.ArtistFirstName = (string)node.GetXElement(Constants.WorkArtist.workArtistFirstNameElement); artist.ArtistName4 = (string)node.GetXElement(Constants.WorkArtist.workArtistName4Element); artist.ArtistName5 = (string)node.GetXElement(Constants.WorkArtist.workArtistName5Element); } workArtist.Artist = artist; int workArtistStatus, workArtistStatusID, instrumentID; int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistInstrumentIDElement), out instrumentID); int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistStatusElement), out workArtistStatus); int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistStatusIDElement), out workArtistStatusID); string workArtistNote = (string)node.GetXElement(Constants.WorkArtist.workArtistNoteElement); workArtist = SetWorkArtistData(workArtist, workArtistNote, workArtistStatus, workArtistStatusID); string workArtistInstrument = (string)node.GetXElement(Constants.WorkArtist.workArtistInstrumentElement); string workArtistInstrument2 = (string)node.GetXElement(Constants.WorkArtist.workArtistInstrument2Element); CreateWorkArtistInstrument(workArtist, instrumentID, workArtistInstrument, workArtistInstrument2); return(workArtist); }