private bool DoUpdates(ImportAthleteAction importAthleteAction)
        {
            if (importAthleteAction.Exception != null)
            {
                return(false);
            }

            var athleteMgmt = new AthleteManagement(Global.ConnectionString, SessionProps);

            if (!importAthleteAction.AthleteIsStored ||
                !importAthleteAction.AthleteClubIsStored ||
                !importAthleteAction.AthleteClubIsUpToDate)
            {
                Action <string, Guid> TweetAction = (tweet, athleteClubGuid) =>
                {
                    //no tweeting when mass importing
                };
                athleteMgmt.SaveAthlete(importAthleteAction.AthleteClub.Inti_Athlete.FirstName,
                                        importAthleteAction.AthleteClub.Inti_Athlete.LastName,
                                        importAthleteAction.AthleteClub.Inti_Athlete.GUID,
                                        SelectedTournament,
                                        importAthleteAction.AthleteClub.ClubGUID,
                                        importAthleteAction.AthleteClub.PositionGUID,
                                        importAthleteAction.AthleteClub.Price ?? 0,
                                        true, importAthleteAction.AthleteClub.Inti_Club.ShortName, TweetAction);
            }

            return(true);
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var athleteManagement = new AthleteManagement(Global.ConnectionString, SessionProps);

            var  playerGUIDvar = this.GetRedirectParameter("athleteGUID", false);
            Guid playerGUID    = Guid.Empty;
            Guid newPlayerGUID = Guid.Empty;
            var  newPlayer     = playerGUIDvar == null;

            if (playerGUIDvar != null)
            {
                playerGUID = new Guid(playerGUIDvar.ToString());
            }

            try
            {
                Action <string, Guid> TweetAthlete = (tweet, athleteClubGuid) =>
                {
                    var url = "http://interntipset.com/Player/" + athleteClubGuid.ToString();
                    Global.SendTweet(tweet, url, SessionProps);
                };

                newPlayerGUID = athleteManagement.SaveAthlete(FirstName.Text, LastName.Text, playerGUID, new Guid(drpTournament.SelectedValue),
                                                              (drpClubs.SelectedItem.Text == "---" ? Guid.Empty : new Guid(drpClubs.SelectedValue)),
                                                              (drpPosition.SelectedItem.Text == "---" ? Guid.Empty : new Guid(drpPosition.SelectedValue)),
                                                              int.Parse(Price.Text), IsActive.Checked, drpClubs.SelectedItem.Text, TweetAthlete);
            }
            catch (DuplicateNameException duplicateNameException)
            {
                PlayerEditMessage.Text =
                    "Det finns redan en spelare med detta namnet. Gå tillbaka till söksidan och editera den spelaren om det är samma person. Gör annars namnet unikt.";
            }
            catch (Exception exception)
            {
                PlayerEditMessage.Text = exception.Message;
            }

            if (newPlayerGUID != playerGUID)
            {
                WebControlManager.RedirectWithQueryString("AdminPlayerEdit.aspx", new string[] { "athleteGUID" }, new string[] { newPlayerGUID.ToString() });
            }
        }