Пример #1
0
        private void ContinueAddDropin_Click(object sender, EventArgs e)
        {
            String playerId = Session[Constants.CURRENT_USER_ID].ToString();
            Game   game     = Reservations.FindGameById(GameId);

            if (!this.checkDropinSpotAvailable(game))
            {
                Session[Constants.ACTION_TYPE] = "AddWaitingList";
                ShowPopupModal("Sorry, But all spots are already filled up. Would you like to put on waiting list?");
                return;
            }
            if (!game.Players.Contains(playerId))
            {
                game.Players.Add(playerId);
                if (!String.IsNullOrEmpty(game.WechatName))
                {
                    String[] wechatGroups = game.WechatName.Split(',');
                    foreach (String group in wechatGroups)
                    {
                        String message = "你悄悄地给自己报了名参加" + game.Title + "。目前的报名总人数: " + game.Players.Count;
                        if (game.MaxPlayers > 0)
                        {
                            message = message + ",还有" + (game.MaxPlayers - game.Players.Count) + "个空位";
                        }
                        WechatMessage wechatMessage = new WechatMessage(group, Reservations.FindPlayerById(playerId).Name, message);
                        Reservations.WechatMessages.Add(wechatMessage);
                    }
                }
            }
            DataAccess.Save(Reservations);
            this.PopupModal.Hide();
            Response.Redirect("Activity.aspx");
        }
Пример #2
0
        protected void CancelConfirm_Click(object sender, EventArgs e)
        {
            String userId = Session[Constants.CURRENT_USER_ID].ToString();
            Game   game   = Reservations.FindGameById(GameId);

            if (game.Players.Contains(userId))
            {
                game.Players.Remove(userId);
                if (!String.IsNullOrEmpty(game.WechatName))
                {
                    String[] wechatGroups = game.WechatName.Split(',');
                    foreach (String group in wechatGroups)
                    {
                        String message = "你偷偷的取消了报名参加(" + game.Title + ")。目前的报名总人数: " + game.Players.Count;
                        if (game.MaxPlayers > 0)
                        {
                            message = message + ",还有" + (game.MaxPlayers - game.Players.Count) + "个空位";
                        }
                        WechatMessage wechatMessage = new WechatMessage(group, Reservations.FindPlayerById(userId).Name, message);
                        Reservations.WechatMessages.Add(wechatMessage);
                    }
                }
                Reservations.AssignASpotToWaitingList(game);
            }
            if (!Reservations.SharePlayers)
            {
                Reservations.DeletePlayer(userId);
            }
            DataAccess.Save(Reservations);
            Response.Redirect(Request.RawUrl);
            //this.ConfirmPopup.Hide();
        }
Пример #3
0
        protected void DropinCancelConfirm_Click(object sender, ImageClickEventArgs e)
        {
            String userId = Session[Constants.CURRENT_USER_ID].ToString();
            Game   game   = Reservations.FindGameById(GameId);
            Player player = Reservations.FindPlayerById(userId);

            if (player.FeeIds.Count > 0)
            {
                ShowMessage("This person paid for this activtiy, so cannot be cancelled");
                return;
            }
            if (game.Players.Contains(userId))
            {
                game.Players.Remove(userId);
                if (!String.IsNullOrEmpty(game.WechatName))
                {
                    String[] wechatGroups = game.WechatName.Split(',');
                    foreach (String group in wechatGroups)
                    {
                        String message = "你偷偷的取消了报名参加(" + game.Title + ")。目前的报名总人数: " + game.Players.Count;
                        if (game.MaxPlayers > 0)
                        {
                            message = message + ",还有" + (game.MaxPlayers - game.Players.Count) + "个空位";
                        }
                        WechatMessage wechatMessage = new WechatMessage(group, Reservations.FindPlayerById(userId).Name, message);
                        Reservations.WechatMessages.Add(wechatMessage);
                        Reservations.AssignASpotToWaitingList(game);
                    }
                }
            }
            else
            {
                game.WaitingListIds.Remove(userId);
            }
            if (!Reservations.SharePlayers)
            {
                //Reservations.DeletePlayer(userId);
            }
            DataAccess.Save(Reservations);
            this.PopupModal.Hide();
            Response.Redirect("Activity.aspx");
        }
Пример #4
0
 public void AssignASpotToWaitingList(Game game)
 {
     if (game.WaitingListIds.Count > 0)
     {
         if (!game.Players.Contains(game.WaitingListIds[0]))
         {
             game.Players.Add(game.WaitingListIds[0]);
             if (!String.IsNullOrEmpty(game.WechatName))
             {
                 String message = "恭喜你报上的名参加" + game.Title + "。目前的报名总人数: " + game.Players.Count;
                 if (game.MaxPlayers > 0)
                 {
                     message = message + ",还有" + (game.MaxPlayers - game.Players.Count) + "个空位";
                 }
                 WechatMessage wechatMessage = new WechatMessage(game.WechatName, FindPlayerById(game.WaitingListIds[0]).Name, message);
                 wechatMessages.Add(wechatMessage);
             }
         }
         game.WaitingListIds.RemoveAt(0);
     }
 }