Ejemplo n.º 1
0
        /// <summary>
        /// Renders the HTML for an add season form.
        /// </summary>
        /// <param name="teamID">The ID of the team to which the season would be added.</param>
        /// <returns>The HTML for the form.</returns>
        public ActionResult AJAX_RenderAddSeasonForm(long teamID)
        {
            string result = "Request is not authenticated.";
            if (Request.IsAuthenticated) {
                DBAccessor dba = new DBAccessor();
                List<Season> seasons = dba.GetSeasons(teamID);

                result = "<form><select class='editor-field' name='yearpicker' id='yearpicker'>";
                for (int i = 0; i < 5; i++) {
                    Season tempSeason = new Season();
                    tempSeason.year = (short)(DateTime.Now.Year + i);
                    if (!seasons.Contains(tempSeason, new SeasonComparer())) {
                        result += "<option value='" + tempSeason.year + "'>" + tempSeason.year + "</option>";
                    }
                }
                result += "</select>";

                result += "<div class='submit-button' onClick='action_addseason()'>Add Season</div>";
                result += "<div id='add-season-feedback'></div></form>";
            }

            // Return the success message of the removal
            return Json(
                new { message = result },
                JsonRequestBehavior.AllowGet
            );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get's the seasons tied to the team with the given ID in the form of an 
        /// unordered list.
        /// </summary>
        /// <param name="teamID">The ID of the team in interest.</param>
        /// <returns>An unordered list of the seasons.</returns>
        public ActionResult AJAX_GetSeasons(long teamID)
        {
            string result = "Request is not authenticated.";
            if (Request.IsAuthenticated) {
                DBAccessor dba = new DBAccessor();
                Team team = dba.GetTeamDetails(teamID);
                Person user = new Person();
                user.email = User.Identity.Name;

                if (team.coaches.Contains(user, new PersonComparer()) || team.players.Contains(user, new PersonComparer())) {
                    List<Season> seasons = dba.GetSeasons(teamID);
                    if (seasons.Any()) {
                        result = "<ul>";
                        foreach (Season season in seasons) {
                            result += "<li>" + season.year + "</li>";
                        }
                        result += "</ul>";
                    }
                    else {
                        result = "<p>There are currently no seasons for this team.</p>";
                    }
                }
                else {
                    result = "You must be on the team or a coach of the team to view the seasons.";

                    LogEntry entry = new LogEntry(LogType.INVALID_REQUEST, LogFunction.GET_SEASONS, LogAction.NA);
                    entry.User = user;
                    entry.Message = "Attempt to view seasons of " + team.name + " ("+team.ID+").";
                    dba.LogMessage(entry);
                }
            }

            // Return the success message of the removal
            return Json(
                new { message = result },
                JsonRequestBehavior.AllowGet
            );
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders the HTML for an add practice form.
        /// </summary>
        /// <param name="teamID"></param>
        /// <returns></returns>
        public ActionResult AJAX_RenderAddPracticeForm(long teamID)
        {
            string result = "Request is not authenticated.";
            if (Request.IsAuthenticated) {
                DBAccessor dba = new DBAccessor();
                List<Season> seasons = dba.GetSeasons(teamID);

                result = "<form>";
                result += "<h4>Location</h4>";
                result += "<input class='editor-field' type='text' name='add-practice-location' />\n";
                result += "<div style='width: 200px;'><div class='leftColB'>";
                result += "<h4>Date</h4>";
                result += "<input id='add-practice-datepicker' class='editor-field' type='text' name='add-practice-date' readonly='readonly' style='width: 90px;' />\n";
                result += "</div><div class='rightColB'>";
                result += "<h4 style='margin-left: 10px;'>Time</h4>";
                result += "<input id='add-practice-timepicker' class='editor-field' type='text' name='add-practice-time' readonly='readonly' style='width: 90px; margin-left: 10px;' />\n";
                result += "</div><div class='clear'></div></div>";
                result += "<h4>Season</h4>";
                result += "<select class='editor-field' name='add-practice-season' id='add-practice-season'>";
                foreach (Season season in seasons) {
                    if (season.year == DateTime.Now.Year) {
                        result += "<option value='" + season.ID + "' selected='selected'>" + season.year + "</option>";
                    }
                    else {
                        result += "<option value='" + season.ID + "'>" + season.year + "</option>";
                    }
                }
                result += "</select>";
                result += "<div class='submit-button' onClick='action_addpractice()'>Add Practice</div>";
                result += "<div id='add-practice-feedback'></div></form>";
                result += "<script>$('#add-practice-datepicker').datepicker({ dateFormat: 'm/dd' });</script>";
                result += "<script>$('#add-practice-timepicker').timepicker({ timeFormat: 'h:mm TT' });</script>";
            }

            // Return the success message of the removal
            return Json(
                new { message = result },
                JsonRequestBehavior.AllowGet
            );
        }