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

                    if (this.Page.IsValid)
                    {
                        using (SqlContextDataContext con = new SqlContextDataContext())
                        {
                            tblTeamBet NewBet = new tblTeamBet
                            {
                                fkCreatorUserId    = (int)Session["UserId"],
                                intWeekNumber      = ddlWeekNumber.SelectedIndex,
                                strTeam            = ddlTeams.SelectedItem.Text,
                                fkStatType         = ddlTeamArguments.SelectedItem.Text,
                                strLogicArgument   = ddlTeamLogic.SelectedItem.Text,
                                decArgumentValue   = Convert.ToDecimal(txtTeamArgumentValue.Text),
                                datDateTimeCreated = DateTime.Now,
                                decMoneyWager      = Convert.ToDecimal(txtTeamWagerAmount.Text.Trim()),
                                blnBetIsOpened     = true
                            };

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


                        pnlBetCreationIsSuccessful.Visible = true;
                    }
                }
            }
        }
Ejemplo 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();
                }
            }
        }
Ejemplo 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")
            {
            }
        }
Ejemplo n.º 4
0
        private void SendTeamBetEmail(string EmailAddressToSendTo, string EmailTopic, string EmailMessage, tblTeamBet Bet)
        {
            MailMessage mail = new MailMessage();

            StringBuilder message = new StringBuilder();

            message.Append(Bet.strLogicArgument);
            message.Append("<br />");
            message.Append("<br />");



            mail.IsBodyHtml = true;
            mail.Body       = message.ToString();
            mail.Subject    = "Social Sports PassWord Reset Link";

            mail.From = new MailAddress("NoReply@SocialSports", "SocialSports");
            mail.To.Add(new MailAddress(EmailAddressToSendTo));



            SmtpClient c = new SmtpClient();

            c.Port = 587;
            c.Host = "smtp.gmail.com";

            c.Credentials    = new System.Net.NetworkCredential("*****@*****.**", "11111111");
            c.DeliveryMethod = SmtpDeliveryMethod.Network;
            c.EnableSsl      = true;

            c.Send(mail);
        }
Ejemplo n.º 5
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();
                }
            }
        }