//
        // GET: /Game/Edit/5

        public ActionResult Edit(int id = 0)
        {
            FoxTickerEntities db = new FoxTickerEntities();
            spTICK_Games_GetByEntryID_Result Game;

            //if (id != 0)
            //{
            if (id == 0)
            {
                return(View(new Game()));
            }

            Game = db.spTICK_Games_GetByEntryID(0, id, 2, false, false).First();;
            if (Game == null)
            {
                return(HttpNotFound());
            }
            ViewData["Games"] = db.spTICK_Games_GetByEntryID(0, id, 2, false, false).First();

            //ViewData["Users"] = db.Users.Distinct().Select(a => new { ID = a.UserID, Name = a.FirstName + " " + a.LastName });
            //}
            //else
            //    Game = new Game();

            //null team
            Team newTeam = new Team();

            newTeam.ID       = -1;
            newTeam.NickName = "NONE";


            List <Team> teams = new List <Team>();

            teams.Add(newTeam);

            //foreach (Note n in db.Notes.Where(n => n.GameID == id))
            //{
            //    int iSport = db.Teams.Where(t => t.ID == n.TeamID).FirstOrDefault().SportID;
            //    if (teams.Where(t => t.SportID == iSport).Count() == 0)
            //        teams.AddRange(db.Teams.Where(tw => tw.SportID == iSport).ToList());
            //}
            teams.AddRange(db.Teams.ToList());

            ViewData["Teams"] = teams;
            //if (Game.TeamID != null)
            //    if (Game.TeamID != -1 && Game.TeamID != 0)
            //        ViewData["SportID"] = db.Teams.Single(s => s.ID == Game.TeamID).SportID;
            return(View(Game));
        }
Example #2
0
        public void Load(int EntryID, int ClientID, int EntryTypeID, bool onlyFinals, bool onlySorted)
        {
            ID          = EntryID;
            clientID    = ClientID;
            entryTypeID = EntryTypeID;

            bOnlyFinals = onlyFinals;
            bOnlySorted = onlySorted;

            Games = db.spTICK_Games_GetByEntryID(clientID, ID, entryTypeID, bOnlyFinals, bOnlySorted).Except(GamesOmitted, new spTICK_Games_GetByEntryID_ResultComparer()).ToList();

            if (Games == null)
            {
                throw new Exception("No Games available.");
            }

            ieGames = Games.GetEnumerator();
        }
        //
        // GET: /Game/Details/5

        public ActionResult Details(int id = 0)
        {
            spTICK_Games_GetByEntryID_Result Game = db.spTICK_Games_GetByEntryID(0, id, 2, false, false).First();

            if (Game == null)
            {
                return(HttpNotFound());
            }
            return(View(Game));
        }
Example #4
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
                    }));
                }
            }
        }