Exemplo n.º 1
0
        public ActionResult ListAttendance()
        {
            var             users          = Session["Users"] as Users;
            List <Practice> getAllPractice = practiceBLL.GetPractice().FindAll(m => m.TeamID == users.TeamID);


            return(View(getAllPractice));
        }
Exemplo n.º 2
0
        public List <Practice> PracticeByUser(Users users)
        {
            //Get all practices
            List <Practice> teamPractices = practiceBLL.GetPractice().FindAll(m => m.TeamID == users.TeamID);

            //if practice are null set to null singleton
            if (teamPractices == null)
            {
                teamPractices.Add(Practice.Null);
            }

            return(teamPractices);
        }
        public ActionResult AddPractice(PracticeModel practice)
        {
            if (ModelState.IsValid)
            {
                var user = Session["Users"] as Users;
                //Map to common object
                PracticeMapper practiceMap = new PracticeMapper();
                Practice       newPractice = practiceMap.PracticeMap(practice);
                newPractice.TeamID = user.TeamID;

                practiceBLL.CreatePractice(newPractice);
                List <Practice> getPractice = practiceBLL.GetPractice();

                if (getPractice.Exists(m => m.PracticeType == newPractice.PracticeType))
                {
                    ViewBag.Message = "Practice Added";
                }
                else
                {
                    ViewBag.Message = "Practice Failed";
                }
            }
            return(View());
        }
        //Method that combines Game and practice into one
        private List <EventGet> CalendarGet()
        {
            //Set variables to populate list to store in List<Events>
            List <Practice> getPractice = new List <Practice>();
            List <Game>     getGames    = new List <Game>();
            //create a team bll to get team names



            List <Team> getTeam = team.GetTeams();
            var         users   = Session["Users"] as Users;

            //populate lists
            getPractice = practiceBLL.GetPractice().FindAll(m => m.TeamID == users.TeamID);
            getGames    = gameBLL.GetGames();
            //Add the Games to the list that matches the login users team id
            List <Game> MyTeamGames = new List <Game>();

            MyTeamGames = getGames.FindAll(m => m.HomeTeam == users.TeamID).ToList();

            List <Game> MyAwayGames = getGames.FindAll(m => m.AwayTeam == users.TeamID).ToList();
            //Add practice to the list that matches the Login Users team ID
            //Create Event List
            List <EventGet> addEvents = new List <EventGet>();

            foreach (Practice practice in getPractice)
            {
                //populate an event object for each practice from the database to add to full calendar
                EventGet events     = new EventGet();
                int      practiceId = 001;
                events.EventID     = practiceId;
                events.Title       = "Practice";
                events.Description = practice.PracticeType;
                events.Start       = practice.StartTime;
                events.End         = practice.EndTime;
                //events.StatusColor = System.Drawing.Color.Green;
                //events.BackgroundColor = System.Drawing.Color.Aqua;
                addEvents.Add(events);
                practiceId++;
            }
            foreach (Game games in MyTeamGames)
            {
                //Get Team Name For Home and Away
                Team teamHome = getTeam.Find(m => m.TeamID == games.HomeTeam);
                Team teamAway = getTeam.Find(m => m.TeamID == games.AwayTeam);

                //populate the event object for Each Home Game
                EventGet events = new EventGet();
                int      gameId = 100;
                events.EventID     = gameId;
                events.Title       = teamHome.TeamName + " " + "vs" + " " + teamAway.TeamName;;
                events.Description = teamHome.TeamName + " Score:" + games.HomeTeamScore.ToString() + " " + teamAway.TeamName + " Score:" + games.AwayTeamScore.ToString();
                events.Start       = games.StartTime;
                events.End         = games.EndTime;
                //events.StatusColor = System.Drawing.Color.Orange;
                //events.BackgroundColor = System.Drawing.Color.Blue;
                addEvents.Add(events);
                gameId++;
            }
            foreach (Game games in MyAwayGames)
            {
                //Get Team Name For Home and Away
                Team teamHome = getTeam.Find(m => m.TeamID == games.HomeTeam);
                Team teamAway = getTeam.Find(m => m.TeamID == games.AwayTeam);

                //populate the event object for Each Away Game
                EventGet events = new EventGet();
                int      gameId = 01;
                events.EventID     = gameId;
                events.Title       = teamHome.TeamName + " " + "vs" + " " + teamAway.TeamName;;
                events.Description = teamHome.TeamName + " Score:" + games.HomeTeamScore.ToString() + " " + teamAway.TeamName + " Score:" + games.AwayTeamScore.ToString();
                events.Start       = games.StartTime;
                events.End         = games.EndTime;
                //events.StatusColor = System.Drawing.Color.Black;
                //events.BackgroundColor = System.Drawing.Color.Gold;
                addEvents.Add(events);
                gameId++;
            }
            return(addEvents);
        }
        public static string FormatPracticeID(int id)
        {
            Practice findPractice = practiceBLL.GetPractice().Find(m => m.PracticeID == id);

            return(findPractice.PracticeType.ToString());
        }