Ejemplo n.º 1
0
        public void LoadGame(int GameID, int ClientID)
        {
            Type     = NoteType.Game;
            gameID   = GameID;
            clientID = ClientID;

            try
            {
                gameNotes = db.spTICK_GameNotes_GetByGameID(gameID, clientID).Except(gameNotesOmitted, new spTICK_GameNotes_GetByGameID_ResultComparer()).ToList();
            }
            catch (Exception ex)
            {
                if (ex.Message == "The underlying provider failed on Open.")
                {
                    throw ex;
                }
            }
            if (gameNotes == null)
            {
                throw new Exception("No Notes available.");
            }

            iegameNotes = gameNotes.GetEnumerator();
        }
Ejemplo n.º 2
0
        public IEnumerable <dynamic> GetPlaylistItems(int cid, int entryID, int EntryTypeID)
        {
            Utilities.LoadClientShares(db, cid);

            List <dynamic> retGroups = new List <dynamic>();

            if (entryID == 0)
            {
                switch (EntryTypeID)
                {
                case (int)Ticker.Data.Enums.EntryType.Group:     //A group.  The GroupID is defined in the EntryID field.
                {
                    foreach (Client c in db.Clients.Single(s => s.ID == cid).Clients)
                    {
                        retGroups = retGroups.Concat(db.Groups.OrderBy(gob => gob.Name).Where(gw => gw.ClientID == c.ID).Select(g => new
                            {
                                // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding.
                                g.ClientID,
                                g.CreatedName,
                                g.Editable,
                                g.GroupAnimationTypeID,
                                g.Header,
                                g.ID,
                                g.LastUpdated,
                                Name = g.Name + " -" + System.Data.Objects.SqlClient.SqlFunctions.StringConvert((double)db.Notes.Where(gn => gn.GroupID == g.ID).Count()),
                                //g.Notes,
                                g.OnAirName,
                                g.TeamID,
                                g.Type
                                ,
                                ObjectType = "Group"
                                ,
                                hasChildren = db.Notes.Where(gn => gn.GroupID == g.ID).Any()
                            })).ToList();
                    }

                    return(retGroups.Concat(db.Groups.OrderBy(gob => gob.Name).Where(gw => gw.ClientID == cid).Select(g => new
                        {
                            // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding.
                            g.ClientID,
                            g.CreatedName,
                            g.Editable,
                            g.GroupAnimationTypeID,
                            g.Header,
                            g.ID,
                            g.LastUpdated,
                            Name = g.Name + " -" + System.Data.Objects.SqlClient.SqlFunctions.StringConvert((double)db.Notes.Where(gn => gn.GroupID == g.ID).Count()),
                            //g.Notes,
                            g.OnAirName,
                            g.TeamID,
                            g.Type
                            ,
                            ObjectType = "Group"
                            ,
                            hasChildren = db.Notes.Where(gn => gn.GroupID == g.ID).Any()
                        })));
                }

                case (int)Ticker.Data.Enums.EntryType.TodaysGames:     //All games for a given sport for today.  The sport is defined in the EntryID field.
                {
                    foreach (Client c in db.Clients.Single(s => s.ID == cid).Clients)
                    {
                        retGroups = retGroups.Concat(db.spTICK_Games_GetByEntryID(cid, entryID, entryTypeID: EntryTypeID, onlyFinals: false, onlySorted: false).Select(g => new
                            {
                                g.ID,
                                Name        = g.Matchup,
                                ObjectType  = "Game",
                                hasChildren = db.spTICK_GameNotes_GetByGameID(gameID: entryID, clientID: c.ID).Any()
                            })).ToList();
                    }

                    return(retGroups.Concat(db.spTICK_Games_GetByEntryID(cid, entryID, entryTypeID: EntryTypeID, onlyFinals: false, onlySorted: false).Select(g => new
                        {
                            g.ID,
                            Name = g.Matchup,
                            ObjectType = "Game",
                            hasChildren = db.spTICK_GameNotes_GetByGameID(gameID: entryID, clientID: cid).Any()
                        })));
                }
                //         return db.PlaylistDetails.Where(pldw => pldw.EntryID == groupID).Select(g => new
                //{
                //    // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding.
                //    g.EntryID,
                //    Name = g.OnAirName,
                //    g.EntryTypeID,
                //    g.PlaylistID,
                //    g.SortOrder,
                //    hasChildren = true
                //}); ;



                default:
                    return(null);
                }
            }
            else
            {
                switch (EntryTypeID)
                {
                case (int)Ticker.Data.Enums.EntryType.Group:     //A group.  The GroupID is defined in the EntryID field.
                    return(db.Groups.Where(gw => gw.ID == entryID).Select(g => new
                    {
                        // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding.
                        g.ClientID,
                        g.CreatedName,
                        g.Editable,
                        g.GroupAnimationTypeID,
                        g.Header,
                        g.ID,
                        g.LastUpdated,
                        Name = g.OnAirName,
                        //g.Notes,
                        g.OnAirName,
                        g.TeamID,
                        g.Type
                        ,
                        ObjectType = "Group"
                        ,
                        hasChildren = db.Notes.Where(gn => gn.GroupID == entryID).Any()
                    }));

                default:
                    return(null);

                case (int)Ticker.Data.Enums.EntryType.TodaysGames:     //All games for a given sport for today.  The sport is defined in the EntryID field.
                {
                    foreach (Client c in db.Clients.Single(s => s.ID == cid).Clients)
                    {
                        retGroups = retGroups.Concat(db.spTICK_Games_GetByEntryID(cid, entryID, entryTypeID: EntryTypeID, onlyFinals: false, onlySorted: false).Select(g => new
                            {
                                g.ID,
                                Name        = g.Matchup,
                                ObjectType  = "Game",
                                hasChildren = db.spTICK_GameNotes_GetByGameID(gameID: entryID, clientID: c.ID).Any()
                            })).ToList();
                    }


                    return(retGroups.Concat(db.spTICK_Games_GetByEntryID(cid, entryID, entryTypeID: EntryTypeID, onlyFinals: false, onlySorted: false).Select(g => new
                        {
                            g.ID,
                            Name = g.Matchup,
                            ObjectType = "Game",
                            hasChildren = db.spTICK_GameNotes_GetByGameID(gameID: entryID, clientID: cid).Any()
                        })));
                }

                //spTICK_Games_GetByEntryID_Result a = new spTICK_Games_GetByEntryID_Result();

                //dynamic a = new PlaylistDetailsType();
                //dynamic a = new []{ new {ID = 0}, new {Name = "Today"}, new {ObjectType = "Game"}, new {hasChildren = false} };
                //a.ID=0;
                //a.Name="Today";
                //a.ObjectType="Game";
                //a.hasChildren=false;
                //var a = new { ID = 0, Name = "Today", ObjectType = "Game", hasChildren = false };
                ////IEnumerable<dynamic> b = a;
                ////ret.Concat(new []{ new {ID = 0}, new {Name = "Today"}, new {ObjectType = "Game"}, new {hasChildren = false} });
                //ret.Concat(Enumerable.Repeat(a, 1));
                //ret.Concat(db.spTICK_Games_GetByEntryID(id, entryID, entryTypeID: EntryTypeID, onlyFinals: false, onlySorted: false).Select(g => new
                //{
                //    g.ID,
                //    Name = g.Matchup,
                //    ObjectType = "Game",
                //    hasChildren = db.spTICK_GameNotes_GetByGameID(gameID: entryID, clientID: id).Any()
                //}));
                //return ret;
                //         return db.PlaylistDetails.Where(pldw => pldw.EntryID == groupID).Select(g => new
                //{
                //    // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding.
                //    g.EntryID,
                //    Name = g.OnAirName,
                //    g.EntryTypeID,
                //    g.PlaylistID,
                //    g.SortOrder,
                //    hasChildren = true
                //}); ;

                case (int)Ticker.Data.Enums.EntryType.GroupOfGames:
                    return(db.GroupGames.Where(gw => gw.GroupID == entryID)
                           .Select(sg => new { sg.ID, sg.HiveID, sg.GroupID, sg.GameID, sg.SportID, sg.SortOrder })
                           .AsEnumerable()
                           .OrderBy(o => o.SortOrder)
                           .Select(g => new
                    {
                        // Skip the EntityState and EntityKey properties inherited from EF. It would break model binding.
                        Name = "",
                        Type = "DataHive",
                        Header = g.HiveID,
                        HivePrefix = db.Sports.Single(s => s.ID == g.SportID).HivePrefix,
                        g.ID,
                        g.HiveID,
                        g.GroupID,
                        g.GameID,
                        g.SportID,
                        g.SortOrder
                    }));
                }
            }
        }