/// <summary>
        /// Check if WorkArtist object already exists with WorkArtists.
        /// </summary>
        /// <param name="workArtistID"></param>
        /// <returns></returns>
        internal static WorkArtist GetWorkArtistByID(int artistID, int workID)
        {
            WorkArtist workArtist = BsoArchiveEntities.Current.WorkArtists.FirstOrDefault(wa => wa.ArtistID == artistID && wa.WorkID == workID) ??
                                    WorkArtist.NewWorkArtist();

            return(workArtist);
        }
        /// <summary>
        /// Returns a WorkArtist object from a workItem XElement node
        /// </summary>
        /// <param name="node"></param>
        /// <remarks>
        /// Takes a XElement node and extracts the WorkArtist information
        /// and creates a new WorkArtist object and returns it.
        /// </remarks>
        /// <returns></returns>
        public static WorkArtist GetWorkArtistFromNode(System.Xml.Linq.XElement node)
        {
            if (node == null || node.Element(Constants.WorkArtist.workArtistIDElement) == null)
            {
                return(null);
            }

            int workArtistID = 0;

            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistIDElement), out workArtistID);

            WorkArtist workArtist = WorkArtist.NewWorkArtist();

            return(BuildWorkArtist(node, workArtistID, workArtist));
        }
Beispiel #3
0
        /// <summary>
        /// Update OPAS Data
        /// </summary>
        public void UpdateOPASData(XDocument loadDocument)
        {
            var recordsToUpdate = BsoArchiveEntities.Current.OPASUpdates.Where(d => !d.HasBeenUpdated);
            var entitesToUpdate = recordsToUpdate.GroupBy(d => d.TableName);

            foreach (var entity in entitesToUpdate)
            {
                Log.Debug(string.Format("Started update processing of entity: {0}", entity.Key));
                string columnName = entity.FirstOrDefault().ColumnName;
                string tagName    = entity.FirstOrDefault().TagName;
                switch ((Table)Enum.Parse(typeof(Table), entity.Key.ToUpper()))
                {
                case Table.EVENT:
                    opasData = Event.NewEvent();
                    break;

                case Table.ARTIST:
                    opasData = Artist.NewArtist();
                    break;

                case Table.EVENTTYPE:
                    opasData = EventType.NewEventType();
                    break;

                case Table.CONDUCTOR:
                    opasData = Conductor.NewConductor();
                    break;

                case Table.ORCHESTRA:
                    opasData = Orchestra.NewOrchestra();
                    break;

                case Table.PARTICIPANT:
                    opasData = Participant.NewParticipant();
                    break;

                case Table.PROJECT:
                    opasData = Project.NewProject();
                    break;

                case Table.SEASON:
                    opasData = Season.NewSeason();
                    break;

                case Table.EVENTTYPEGROUP:
                    opasData = EventTypeGroup.NewEventTypeGroup();
                    break;

                case Table.VENUE:
                    opasData = Venue.NewVenue();
                    break;

                case Table.WORK:
                    opasData = Work.NewWork();
                    break;

                case Table.WORKARTIST:
                    opasData = WorkArtist.NewWorkArtist();
                    break;
                }
                opasData.UpdateData(loadDocument, columnName, tagName);
                entity.FirstOrDefault().HasBeenUpdated = true;
                BsoArchiveEntities.Current.Detach(opasData);

                Log.Debug(string.Format("Finished update processing of entity: {0}", entity.Key));
            }
            BsoArchiveEntities.Current.Save();
        }