public static EventWork AddEventWork(Event evt, Work work)
        {
            var eventWork = EventWork.NewEventWork();
            eventWork.Event = evt;
            eventWork.Work = work;
            eventWork.WorkPremiere = work.WorkPremiere;

            return eventWork;
        }
        /// <summary>
        /// Add workArtists from XElement workItem and add to Work object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="work"></param>
        /// <remarks>
        /// Gets the WorkArtist objects information from the XElement node and 
        /// gets the WorkArtist object. Then adds it to Work's WorkArtists collection.
        /// </remarks>
        /// <returns></returns>
        public static Work GetWorkArtists(System.Xml.Linq.XElement node, Work work)
        {
            IEnumerable<System.Xml.Linq.XElement> workArtistElements = node.Descendants("workArtist");
            foreach (System.Xml.Linq.XElement workArtist in workArtistElements)
            {
                WorkArtist artist = WorkArtist.GetWorkArtistFromNode(workArtist);

                if (artist == null) continue;

                Work.AddWorkArtist(work, artist);
            }
            return work;
        }
 /// <summary>
 /// Create a new Work object.
 /// </summary>
 /// <param name="workID">Initial value of the WorkID property.</param>
 /// <param name="workTitle">Initial value of the WorkTitle property.</param>
 /// <param name="workTitle2">Initial value of the WorkTitle2 property.</param>
 /// <param name="workTitle3">Initial value of the WorkTitle3 property.</param>
 /// <param name="workArrangement">Initial value of the WorkArrangement property.</param>
 /// <param name="workCompYear">Initial value of the WorkCompYear property.</param>
 /// <param name="workCompYear2">Initial value of the WorkCompYear2 property.</param>
 /// <param name="workPremiere">Initial value of the WorkPremiere property.</param>
 /// <param name="workCommission">Initial value of the WorkCommission property.</param>
 /// <param name="workRegular">Initial value of the WorkRegular property.</param>
 /// <param name="workIntermission">Initial value of the WorkIntermission property.</param>
 /// <param name="workFlute">Initial value of the WorkFlute property.</param>
 /// <param name="workOboe">Initial value of the WorkOboe property.</param>
 /// <param name="workClarinet">Initial value of the WorkClarinet property.</param>
 /// <param name="workBassoon">Initial value of the WorkBassoon property.</param>
 /// <param name="workHorn">Initial value of the WorkHorn property.</param>
 /// <param name="workTrumpet">Initial value of the WorkTrumpet property.</param>
 /// <param name="workTrombone">Initial value of the WorkTrombone property.</param>
 /// <param name="workTuba">Initial value of the WorkTuba property.</param>
 /// <param name="workTimpani">Initial value of the WorkTimpani property.</param>
 /// <param name="workPercussion">Initial value of the WorkPercussion property.</param>
 /// <param name="workHarp">Initial value of the WorkHarp property.</param>
 /// <param name="workKeyboard">Initial value of the WorkKeyboard property.</param>
 /// <param name="workExtra">Initial value of the WorkExtra property.</param>
 /// <param name="workViolin1">Initial value of the WorkViolin1 property.</param>
 /// <param name="workViolin2">Initial value of the WorkViolin2 property.</param>
 /// <param name="workViola">Initial value of the WorkViola property.</param>
 /// <param name="workCello">Initial value of the WorkCello property.</param>
 /// <param name="workBass">Initial value of the WorkBass property.</param>
 /// <param name="workNote">Initial value of the WorkNote property.</param>
 /// <param name="workDetail">Initial value of the WorkDetail property.</param>
 /// <param name="workStatus">Initial value of the WorkStatus property.</param>
 /// <param name="isCommission">Initial value of the IsCommission property.</param>
 /// <param name="workStatusID">Initial value of the WorkStatusID property.</param>
 /// <param name="composerID">Initial value of the ComposerID property.</param>
 /// <param name="createdBy">Initial value of the CreatedBy property.</param>
 /// <param name="createdOn">Initial value of the CreatedOn property.</param>
 /// <param name="modifiedBy">Initial value of the ModifiedBy property.</param>
 /// <param name="modifiedOn">Initial value of the ModifiedOn property.</param>
 /// <param name="stamp">Initial value of the Stamp property.</param>
 /// <param name="active">Initial value of the Active property.</param>
 /// <param name="workGroupID">Initial value of the WorkGroupID property.</param>
 /// <param name="workAddTitle1">Initial value of the WorkAddTitle1 property.</param>
 /// <param name="workAddTitle2">Initial value of the WorkAddTitle2 property.</param>
 /// <param name="workAddTitle3">Initial value of the WorkAddTitle3 property.</param>
 /// <param name="workAddTitleText">Initial value of the WorkAddTitleText property.</param>
 public static Work CreateWork(global::System.Int32 workID, global::System.String workTitle, global::System.String workTitle2, global::System.String workTitle3, global::System.String workArrangement, global::System.String workCompYear, global::System.String workCompYear2, global::System.String workPremiere, global::System.String workCommission, global::System.String workRegular, global::System.String workIntermission, global::System.Int32 workFlute, global::System.Int32 workOboe, global::System.Int32 workClarinet, global::System.Int32 workBassoon, global::System.Int32 workHorn, global::System.Int32 workTrumpet, global::System.Int32 workTrombone, global::System.Int32 workTuba, global::System.Int32 workTimpani, global::System.Int32 workPercussion, global::System.Int32 workHarp, global::System.Int32 workKeyboard, global::System.Int32 workExtra, global::System.Int32 workViolin1, global::System.Int32 workViolin2, global::System.Int32 workViola, global::System.Int32 workCello, global::System.Int32 workBass, global::System.String workNote, global::System.String workDetail, global::System.Int32 workStatus, global::System.Boolean isCommission, global::System.Int32 workStatusID, global::System.Int32 composerID, global::System.Int32 createdBy, global::System.DateTime createdOn, global::System.Int32 modifiedBy, global::System.DateTime modifiedOn, global::System.Byte[] stamp, global::System.Boolean active, global::System.Int32 workGroupID, global::System.String workAddTitle1, global::System.String workAddTitle2, global::System.String workAddTitle3, global::System.String workAddTitleText)
 {
     Work work = new Work();
     work.WorkID = workID;
     work.WorkTitle = workTitle;
     work.WorkTitle2 = workTitle2;
     work.WorkTitle3 = workTitle3;
     work.WorkArrangement = workArrangement;
     work.WorkCompYear = workCompYear;
     work.WorkCompYear2 = workCompYear2;
     work.WorkPremiere = workPremiere;
     work.WorkCommission = workCommission;
     work.WorkRegular = workRegular;
     work.WorkIntermission = workIntermission;
     work.WorkFlute = workFlute;
     work.WorkOboe = workOboe;
     work.WorkClarinet = workClarinet;
     work.WorkBassoon = workBassoon;
     work.WorkHorn = workHorn;
     work.WorkTrumpet = workTrumpet;
     work.WorkTrombone = workTrombone;
     work.WorkTuba = workTuba;
     work.WorkTimpani = workTimpani;
     work.WorkPercussion = workPercussion;
     work.WorkHarp = workHarp;
     work.WorkKeyboard = workKeyboard;
     work.WorkExtra = workExtra;
     work.WorkViolin1 = workViolin1;
     work.WorkViolin2 = workViolin2;
     work.WorkViola = workViola;
     work.WorkCello = workCello;
     work.WorkBass = workBass;
     work.WorkNote = workNote;
     work.WorkDetail = workDetail;
     work.WorkStatus = workStatus;
     work.IsCommission = isCommission;
     work.WorkStatusID = workStatusID;
     work.ComposerID = composerID;
     work.CreatedBy = createdBy;
     work.CreatedOn = createdOn;
     work.ModifiedBy = modifiedBy;
     work.ModifiedOn = modifiedOn;
     work.Stamp = stamp;
     work.Active = active;
     work.WorkGroupID = workGroupID;
     work.WorkAddTitle1 = workAddTitle1;
     work.WorkAddTitle2 = workAddTitle2;
     work.WorkAddTitle3 = workAddTitle3;
     work.WorkAddTitleText = workAddTitleText;
     return work;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Works EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWorks(Work work)
 {
     base.AddObject("Works", work);
 }
        public static Work NewWork()
        {
            Work newObject = new Work();

            BsoArchiveEntities.Current.AddToWorks(newObject);
            BsoArchiveEntities.SetDefaultValue(newObject);
            return newObject;
        }
        /// <summary>
        /// Sets the titles of the Work object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="work"></param>
        /// <remarks>
        /// Extracts the 3 Titles from the XElement node and assigns them 
        /// to the Work object then returns that object.
        /// </remarks>
        /// <returns></returns>
        private static Work SetWorkTitles(System.Xml.Linq.XElement node, Work work)
        {
            string workTitle = (string)node.GetXElement(Constants.Work.workTitleElement);
            string workTitle2 = (string)node.GetXElement(Constants.Work.workTitle2Element);
            string workTitle3 = (string)node.GetXElement(Constants.Work.workTitle3Element);
            work.WorkTitle = workTitle;
            work.WorkTitle2 = workTitle2;
            work.WorkTitle3 = workTitle3;

            var workAddTitle = node.Element(Constants.Work.workAddTitleElement);
            if(workAddTitle != null)
                SetAddedSecondaryTitles(workAddTitle, work);

            return work;
        }
        /// <summary>
        /// Sets the instrument variables to the Work object.
        /// </summary>
        /// <param name="work"></param>
        /// <param name="flute"></param>
        /// <param name="oboe"></param>
        /// <param name="clarinet"></param>
        /// <param name="bassoon"></param>
        /// <param name="horn"></param>
        /// <param name="trumpet"></param>
        /// <param name="trombone"></param>
        /// <param name="tuba"></param>
        /// <param name="timpani"></param>
        /// <param name="percussion"></param>
        /// <param name="harp"></param>
        /// <param name="keyboard"></param>
        /// <param name="extra"></param>
        /// <param name="violin1"></param>
        /// <param name="violin2"></param>
        /// <param name="viola"></param>
        /// <param name="bass"></param>
        /// <returns></returns>
        private static Work SetWorkInstruments(Work work, int flute, int oboe, int clarinet, int bassoon, int horn, int trumpet, int trombone, int tuba, int timpani, int percussion, int harp, int keyboard, int extra, int violin1, int violin2, int viola, int bass)
        {
            work.WorkFlute = flute;
            work.WorkOboe = oboe;
            work.WorkClarinet = clarinet;
            work.WorkBassoon = bassoon;
            work.WorkHorn = horn;
            work.WorkTrumpet = trumpet;
            work.WorkTrombone = trombone;
            work.WorkTuba = tuba;
            work.WorkTimpani = timpani;
            work.WorkPercussion = percussion;
            work.WorkHarp = harp;
            work.WorkKeyboard = keyboard;
            work.WorkExtra = extra;
            work.WorkViolin1 = violin1;
            work.WorkViolin2 = violin2;
            work.WorkViola = viola;
            work.WorkBass = bass;

            return work;
        }
        /// <summary>
        /// Assigns data from XElement node to Work object.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="workID"></param>
        /// <param name="work"></param>
        /// <remarks>
        /// Extracts information about the workItem from the XElement 
        /// node then assigns it to the Work object variables.
        /// </remarks>
        /// <returns></returns>
        private static Work SetWorkData(System.Xml.Linq.XElement node, int workID, Work work)
        {
            int workGroupID = 0;
            int.TryParse((string)node.GetXElement(Constants.Work.workGroupIDElement), out workGroupID);
            string workArrangement = (string)node.GetXElement(Constants.Work.workArrangementElement);
            string workCompYear = (string)node.GetXElement(Constants.Work.workCompYearElement);
            string workCompYear2 = (string)node.GetXElement(Constants.Work.workCompYear2Element);
            string workPremiere = (string)node.GetXElement(Constants.Work.workPremiereElement);
            string workRegular = (string)node.GetXElement(Constants.Work.workRegularElement);
            string workIntermission = (string)node.GetXElement(Constants.Work.workIntermissionElement);
            string workNote = node.GetXElement(Constants.Work.workNoteElement);
            string workCommission = node.GetXElement(Constants.Work.workCommissionElement);

            work.WorkGroupID = workGroupID;
            work.WorkNote = workNote;
            work.WorkArrangement = workArrangement;
            work.WorkCompYear = workCompYear;
            work.WorkCompYear2 = workCompYear;
            work.WorkPremiere = workPremiere;
            work.WorkCommission = workCommission;
            work.WorkRegular = workRegular;
            work.WorkIntermission = workIntermission;
            work.WorkID = workID;

            return work;
        }
 /// <summary>
 /// Set added titles of the Work object
 /// </summary>
 /// <remarks>
 /// Adds the alternate titles that will be used with titles that have diacritics
 /// </remarks>
 /// <param name="node"></param>
 /// <param name="work"></param>
 private static void SetAddedSecondaryTitles(System.Xml.Linq.XElement node, Work work)
 {
     work.WorkAddTitle1 = (string)node.GetXElement(Constants.Work.workAddTitleTitle1Element);
     work.WorkAddTitle2 = (string)node.GetXElement(Constants.Work.workAddTitleTitle2Element);
     work.WorkAddTitle3 = (string)node.GetXElement(Constants.Work.workAddTitleTitle3Element);
     work.WorkAddTitleText = (string)node.GetXElement(Constants.Work.workAddTitleTextElement);
 }
        /// <summary>
        /// Get the instrument variables from the XElement node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="work"></param>
        /// <remarks>
        /// Extracts the values representing the instruments in the XElement node. Then 
        /// it calls SetWorkInstruments to assign them to the Work object.
        /// </remarks>
        /// <returns></returns>
        private static Work GetWorkInstruments(System.Xml.Linq.XElement node, Work work)
        {
            int flute, oboe, clarinet, bassoon, horn, trumpet, trombone, tuba, timpani,
                percussion, harp, keyboard, extra, violin1, violin2, viola, cello, bass;
            int.TryParse((string)node.GetXElement(Constants.Work.workFluteElement), out flute);
            int.TryParse((string)node.GetXElement(Constants.Work.workOboeElement), out oboe);
            int.TryParse((string)node.GetXElement(Constants.Work.workClarinetElement), out clarinet);
            int.TryParse((string)node.GetXElement(Constants.Work.workBassoonElement), out bassoon);
            int.TryParse((string)node.GetXElement(Constants.Work.workHornElement), out horn);
            int.TryParse((string)node.GetXElement(Constants.Work.workTrumpetElement), out trumpet);
            int.TryParse((string)node.GetXElement(Constants.Work.workTromboneElement), out trombone);
            int.TryParse((string)node.GetXElement(Constants.Work.workTubaElement), out tuba);
            int.TryParse((string)node.GetXElement(Constants.Work.workTimpaniElement), out timpani);
            int.TryParse((string)node.GetXElement(Constants.Work.workPercussionElement), out percussion);
            int.TryParse((string)node.GetXElement(Constants.Work.workHarpElement), out harp);
            int.TryParse((string)node.GetXElement(Constants.Work.workKeyboardElement), out keyboard);
            int.TryParse((string)node.GetXElement(Constants.Work.workExtraElement), out extra);
            int.TryParse((string)node.GetXElement(Constants.Work.workViolin1Element), out violin1);
            int.TryParse((string)node.GetXElement(Constants.Work.workViolin2Element), out violin2);
            int.TryParse((string)node.GetXElement(Constants.Work.workViolaElement), out viola);
            int.TryParse((string)node.GetXElement(Constants.Work.workCelloElement), out cello);
            int.TryParse((string)node.GetXElement(Constants.Work.workBassElement), out bass);

            work = SetWorkInstruments(work, flute, oboe, clarinet, bassoon, horn, trumpet, trombone, tuba, timpani, percussion, harp, keyboard, extra, violin1, violin2, viola, bass);

            return work;
        }
        private static Work GetComposers(System.Xml.Linq.XElement node, Work work)
        {
            var composerNode = node.Element(Constants.Composer.composerElement);
            Composer composer = Composer.GetComposerFromNode(composerNode);

            work.Composer = composer;

            return work;
        }
        /// <summary>
        /// Add WorkArtist object to WorkArtists in Work
        /// </summary>
        /// <param name="work"></param>
        /// <param name="artist"></param>
        /// <remarks>
        /// Checks to see if the Work object's collection of WorkArtists contains 
        /// the WorkArtist object passed. If yes then just return, otherwise Add.
        /// </remarks>
        internal static void AddWorkArtist(Work work, WorkArtist artist)
        {
            var wArtist = work.WorkArtists.FirstOrDefault(wa => wa.ArtistID == artist.ArtistID && wa.WorkID == work.WorkID);

            if (wArtist != null) return;

            work.WorkArtists.Add(artist);
        }
        /// <summary>
        /// Add an event work
        /// </summary>
        /// <param name="work"></param>
        /// <remarks>
        /// Check if the event work exists. If it does then return the event work object, otherwise
        /// create a new event work object and return it.
        /// </remarks>
        /// <returns></returns>
        public EventWork AddEventWork(Work work)
        {
            var eventWork = this.EventWorks.FirstOrDefault(ep => ep.WorkID == work.WorkID && ep.WorkPremiere == work.WorkPremiere);

            if (eventWork != null) return eventWork;

            eventWork = EventWork.AddEventWork(this, work);

            return eventWork;
        }