Exemplo n.º 1
0
        protected void btnCreatePlayerBet_Click(object sender, EventArgs e)
        {
            if (Session["UserId"] != null)
            {
                if (rdoTypeOfBet.SelectedIndex == 1)
                {
                    this.Page.Validate("PlayerBet");

                    if (this.Page.IsValid)
                    {
                        using (SqlContextDataContext con = new SqlContextDataContext())
                        {
                            tblPlayerBet NewBet = new tblPlayerBet
                            {
                                fkCreatorUserId    = (int)Session["UserId"],
                                intWeekNumber      = ddlWeekNumber.SelectedIndex,
                                strPlayerName      = ddlPlayers.SelectedItem.Text,
                                fkStatType         = ddlPlayerArguments.SelectedItem.Text,
                                strLogicArgument   = ddlPlayersLogic.SelectedItem.Text,
                                decArgumentValue   = Convert.ToDecimal(txtPlayerArgumentValue.Text),
                                decMoneyWager      = Convert.ToDecimal(txtPlayerWagerAmount.Text.Trim()),
                                datDateTimeCreated = DateTime.Now,
                                blnBetIsOpened     = true
                            };

                            con.tblPlayerBets.InsertOnSubmit(NewBet);
                            con.SubmitChanges();
                        }

                        pnlBetCreationIsSuccessful.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void UserAgreeToBet(int BetId, int UserIdWhoCreated, int UserIdWhoAccepted, bool IsTeamBet)
        {
            using (SqlContextDataContext con = new SqlContextDataContext())
            {
                tblLinkUsersToBet NewBetAcceptor = new tblLinkUsersToBet
                {
                    fkUserWhoCreatedId  = UserIdWhoCreated,
                    fkUserWhoAccepted   = UserIdWhoAccepted,
                    fkBetId             = BetId,
                    datDateTimeAccepted = DateTime.Now,
                    blnIsTeamBet        = IsTeamBet
                };

                con.tblLinkUsersToBets.InsertOnSubmit(NewBetAcceptor);
                con.SubmitChanges();

                if (IsTeamBet)
                {
                    tblTeamBet TeamBet = con.tblTeamBets.Single(x => x.pkBetId == BetId);
                    TeamBet.blnBetIsOpened = false;
                    con.SubmitChanges();
                }
                else
                {
                    tblPlayerBet PlayerBet = con.tblPlayerBets.Single(x => x.pkBetId == BetId);
                    PlayerBet.blnBetIsOpened = false;
                    con.SubmitChanges();
                }
            }
        }
Exemplo n.º 3
0
        protected void gvMyCreatedBets_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int      RowIndex     = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
            string   TeamOrPlayer = e.CommandArgument.ToString();
            GridView gv           = (GridView)sender;
            int      BetId        = Convert.ToInt32(((Label)gv.Rows[RowIndex].FindControl("lblBetId")).Text);

            if (e.CommandName == "CancelBet")
            {
                using (SqlContextDataContext context = new SqlContextDataContext())
                {
                    if (TeamOrPlayer == "TeamBet")
                    {
                        tblTeamBet TeamBet = context.tblTeamBets.SingleOrDefault(x => x.pkBetId == BetId);
                        context.tblTeamBets.DeleteOnSubmit(TeamBet);
                        context.SubmitChanges();

                        int TeamLinkCount = context.tblLinkUsersToBets.Count(x => x.fkBetId == BetId && x.blnIsTeamBet == true);

                        if (TeamLinkCount != 0)
                        {
                            tblLinkUsersToBet DeleteBet = context.tblLinkUsersToBets.SingleOrDefault(x => x.fkBetId == BetId && x.blnIsTeamBet == true);
                            context.tblLinkUsersToBets.DeleteOnSubmit(DeleteBet);
                            context.SubmitChanges();
                        }
                    }
                    else
                    {
                        tblPlayerBet PlayerBet = context.tblPlayerBets.SingleOrDefault(x => x.pkBetId == BetId);
                        context.tblPlayerBets.DeleteOnSubmit(PlayerBet);
                        context.SubmitChanges();

                        int PlayerLinkCount = context.tblLinkUsersToBets.Count(x => x.fkBetId == BetId && x.blnIsTeamBet == false);

                        if (PlayerLinkCount != 0)
                        {
                            tblLinkUsersToBet DeleteBet = context.tblLinkUsersToBets.SingleOrDefault(x => x.fkBetId == BetId && x.blnIsTeamBet == false);
                            context.tblLinkUsersToBets.DeleteOnSubmit(DeleteBet);
                            context.SubmitChanges();
                        }
                    }
                }

                GetMyCreatedBets((int)Session["UserId"], 1);
            }
            else if (e.CommandName == "SendBetEmail")
            {
            }
        }
Exemplo n.º 4
0
        //finish

        public static void MakeCopyOBet(int UserId, int BetId, bool IsTeamBet, bool IsOpposite)
        {
            using (SqlContextDataContext context = new SqlContextDataContext())
            {
                if (IsTeamBet)
                {
                    var Results = context.tblTeamBets.Where(y => y.pkBetId == BetId)
                                  .Select(g => new { TeamBets = g });

                    tblTeamBet NewTeamBet = new tblTeamBet();

                    foreach (var Result in Results)
                    {
                        NewTeamBet.strTeam            = Result.TeamBets.strTeam;
                        NewTeamBet.pkBetId            = Result.TeamBets.pkBetId;
                        NewTeamBet.fkStatType         = Result.TeamBets.fkStatType;
                        NewTeamBet.datDateTimeCreated = DateTime.Now;
                        NewTeamBet.decArgumentValue   = Result.TeamBets.decArgumentValue;
                        NewTeamBet.intWeekNumber      = Result.TeamBets.intWeekNumber;
                        NewTeamBet.fkCreatorUserId    = UserId;

                        if (IsOpposite)
                        {
                            if (Result.TeamBets.strLogicArgument.Trim() == "Will Have More Than")
                            {
                                NewTeamBet.strLogicArgument = "Will Have Less Than";
                            }
                            else
                            {
                                NewTeamBet.strLogicArgument = "Will Have More Than";
                            }
                        }
                        else
                        {
                            NewTeamBet.strLogicArgument = Result.TeamBets.strLogicArgument;
                        }

                        NewTeamBet.decMoneyWager = Result.TeamBets.decMoneyWager;
                    }

                    context.tblTeamBets.InsertOnSubmit(NewTeamBet);
                    context.SubmitChanges();
                }
                else
                {
                    var Results = context.tblPlayerBets.Where(y => y.pkBetId == BetId)
                                  .Select(g => new { PlayerBets = g });

                    tblPlayerBet NewPlayerBet = new tblPlayerBet();

                    foreach (var Result in Results)
                    {
                        NewPlayerBet.strPlayerName      = Result.PlayerBets.strPlayerName;
                        NewPlayerBet.pkBetId            = Result.PlayerBets.pkBetId;
                        NewPlayerBet.fkStatType         = Result.PlayerBets.fkStatType;
                        NewPlayerBet.datDateTimeCreated = DateTime.Now;
                        NewPlayerBet.decArgumentValue   = Result.PlayerBets.decArgumentValue;
                        NewPlayerBet.intWeekNumber      = Result.PlayerBets.intWeekNumber;
                        NewPlayerBet.fkCreatorUserId    = UserId;
                        NewPlayerBet.decMoneyWager      = Result.PlayerBets.decMoneyWager;

                        if (IsOpposite)
                        {
                            if (Result.PlayerBets.strLogicArgument.Trim() == "Will Have More Than")
                            {
                                NewPlayerBet.strLogicArgument = "Will Have Less Than";
                            }
                            else
                            {
                                NewPlayerBet.strLogicArgument = "Will Have More Than";
                            }
                        }
                        else
                        {
                            NewPlayerBet.strLogicArgument = Result.PlayerBets.strLogicArgument;
                        }
                    }

                    context.tblPlayerBets.InsertOnSubmit(NewPlayerBet);
                    context.SubmitChanges();
                }
            }
        }