public void ProcessRequest(HttpContext context)
        {
            var userTeamId = context.Request.Params["UserTeamId"];
            if (userTeamId == null)
            {
                //send error
                SendException(context, new BadRequestException("GetUserTeam called without UserTeamId"));
            }
            Guid userTeamGuid;
            if (!Guid.TryParse(userTeamId, out userTeamGuid))
            {
                //send error
                SendException(context, new BadRequestException("GetUserTeam called without valid UserTeamId"));
            }

            var userTeamManagement = new UserTeamManagement(Global.ConnectionString, Global.SessionProperties);
            var userTeam = userTeamManagement.GetTeam(userTeamGuid);

            var userTeamDto = new UserTeamDTO();

            userTeamDto.Id = userTeam.GUID.ToString();
            userTeamDto.Name = userTeam.Name;
            userTeamDto.Description = userTeam.Presentation;

            //are we in a transfer period?
            var transferPeriod = new CommonDataFetches(Global.ConnectionString, Global.SessionProperties);

            JsonResponse(context, userTeamDto);
        }
示例#2
0
        protected void btnToggleFavorite_Click(object sender, EventArgs e)
        {
            var trans = new UserTeamManagement(Global.ConnectionString, SessionProps);

            trans.ToggleUserFavoriteTeam(TeamId);

            LoadTeam();
        }
        protected void btnRemoveDuplicateTransfers_OnClick(object sender, EventArgs e)
        {
            using (var db = Global.GetConnection())
            {
                var teamManagement = new UserTeamManagement(Global.ConnectionString, SessionProps);

                teamManagement.RemoveDuplicateTransfers(db, TeamId);
            }
        }
        protected void btnReOpenTransferTeam_Click(object sender, EventArgs e)
        {
            using (var db = Global.GetConnection())
            {
                //get current transferwindow
                var transferPeriods = db.Inti_TransferPeriod.Where(tf => tf.TournamentGUID == SessionProps.SelectedTournament.GUID).ToList();
                Inti_TransferPeriod transferPeriod = null;
                foreach (var tf in transferPeriods)
                {
                    if (tf.StartDate <= CurrentDate && tf.EndDate >= CurrentDate)
                    {
                        transferPeriod = tf;
                        break;
                    }
                }
                if (transferPeriod != null)
                {
                    Inti_TeamVersion transferVersion = null;
                    Inti_TeamVersion currentVersion = null;

                    GetCurrentAndTransferVersion(db, out currentVersion, out transferVersion);

                    var trans = new UserTeamManagement(Global.ConnectionString, SessionProps);
                    trans.ReOpenTeamForTransfers(db, transferPeriod, transferVersion, currentVersion, TeamId);

                    lblTransferPeriodInfo.Text += "<br><br><span class=\"label label-success\">Nu kan du ändra på bytena...</span>";

                    //are we in transferwindow?
                    CheckTransferWindow(false);

                    LoadTeam();
                }

            }
        }
        private void ShowTransferWindow(Inti_TransferPeriod tf, bool undoChanges)
        {
            //show info about the transfer period
            lblTransferPeriodInfo.Text = "Transferfönstret " + tf.Name + " är öppet från och med " +
                                         tf.StartDate.ToString() + " till " + tf.EndDate + ".";
            lblTransferPeriodInfo.Text += "<br>" + tf.Description;

            pnlFutureLineUp.Visible = false;

            //create new team version if needed
            using (var db = Global.GetConnection())
            {
                Inti_TeamVersion transferVersion = null;
                Inti_TeamVersion currentVersion = null;

                GetCurrentAndTransferVersion(db, out currentVersion, out transferVersion);

                if(transferVersion.ValidFrom == null)
                {
                    lblTransferPeriodInfo.Text += "<br><div class=\"redFrame\"><b>" + "Tänk på att du måste klicka på knappen \"Genomför byten\" ";
                    lblTransferPeriodInfo.Text +=
                        "när du är färdiga med dina byten. Annars tror vi bara att du lattjat runt lite.</b></div>";

                    if ((undoChanges || transferVersion.Inti_TeamAthlete.ToList().Count == 0) && currentVersion != null && transferVersion != null)
                    {
                        var trans = new UserTeamManagement(Global.ConnectionString, SessionProps);
                        trans.ReloadTransferVersion(db, transferVersion, currentVersion, TeamId);
                    }

                    //load transfer controls
                    LoadTransferControls(transferVersion, db);

                    pnlTeamTransfers.Visible = true;
                    btnReOpenTransferTeam.Visible = false;
                }
                else
                {
                    lblTransferPeriodInfo.Text +=
                        "<br><br><span class=\"label label-success\">Dina byten är gjorda.</span> Vill du ändra något, klicka på knappen \"Ångra genomförande av byten\"";
                    lblTransferPeriodInfo.Text +=
                        "<br>Tänk på att du då måste klicka på knappen \"Genomför byten\" igen för att bytena ska gå igenom.";

                    pnlTeamTransfers.Visible = false;
                    btnReOpenTransferTeam.Visible = true;
                }

            }
        }