Exemple #1
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();
                }
            }
        }
Exemple #2
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")
            {
            }
        }
Exemple #3
0
        protected void btnReply_Click(object sender, EventArgs e)
        {
            using (SqlContextDataContext con = new SqlContextDataContext())
            {
                tblChildBulletinBoard Child = new tblChildBulletinBoard()
                {
                    intBoardCreatorUserId = (int)Session["UserId"],
                    datDateTimeCreated    = DateTime.Now,
                    intNumOfLikes         = 0,
                    intParentBoardId      = Convert.ToInt32(Request.QueryString["BulletinId"]),
                    strBoardMessage       = txtReplyBulletin.Text.Trim()
                };

                con.tblChildBulletinBoards.InsertOnSubmit(Child);
                con.SubmitChanges();
            }

            ViewState["BulletinWasPosted"] = true;
            int  BetId     = Convert.ToInt32(Request.QueryString["BetId"]);
            bool IsTeamBet = Request.QueryString["Type"] == null ? true : false;

            if (IsTeamBet)
            {
                Response.Redirect("ViewBet.aspx?BetId=" + BetId.ToString());
            }
            else
            {
                Response.Redirect("ViewBet.aspx?Type=PlayerBet&BetId=" + BetId.ToString());
            }
        }
Exemple #4
0
        protected void btnUploadAvatar_Click(object sender, EventArgs e)
        {
            HttpPostedFile Avatar        = filUploadAvatar.PostedFile;
            string         FileName      = Path.GetFileName(filUploadAvatar.PostedFile.FileName);
            string         FileExtension = Path.GetExtension(FileName);
            int            FileSize      = Avatar.ContentLength;


            if (FileExtension == ".jpg" || FileExtension == ".gif" ||
                FileExtension == ".png" || FileExtension == ".bmp")
            {
                Stream       s          = Avatar.InputStream;
                BinaryReader rdr        = new BinaryReader(s);
                byte[]       ImageBytes = rdr.ReadBytes((int)s.Length);

                using (SqlContextDataContext con = new SqlContextDataContext())
                {
                    tblUser User = con.tblUsers.Single(x => x.pkUserId == (int)Session["UserId"]);
                    User.bytUserImage = ImageBytes;
                    con.SubmitChanges();
                }

                GetUserAvatar((int)Session["UserId"]);
            }
        }
Exemple #5
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;
                    }
                }
            }
        }
Exemple #6
0
        public static bool UserBetApprovals(int BetId, int UserId)
        {
            bool IsAlreadyApproved = false;

            using (SqlContextDataContext con = new SqlContextDataContext())
            {
                int ApprovalCount = con.tblBetApprovals.Where(x => x.fkUserIdWhoApproved == UserId).Count();

                if (ApprovalCount == 0)
                {
                    tblBetApproval NewBetApproval = new tblBetApproval()
                    {
                        fkBetId             = BetId,
                        fkUserIdWhoApproved = UserId
                    };

                    con.tblBetApprovals.InsertOnSubmit(NewBetApproval);
                    con.SubmitChanges();
                }
                else
                {
                    IsAlreadyApproved = true;
                }
            }

            return(IsAlreadyApproved);
        }
Exemple #7
0
        public static void InsertDefaultAvatar(int UserId)
        {
            FileStream fs = new FileStream(System.Web.HttpContext.Current.Server.MapPath("Icons\\default-avatar.jpg"), FileMode.Open);

            using (fs)
            {
                using (BinaryReader binaryReader = new BinaryReader(fs))
                {
                    Byte[] bytes = binaryReader.ReadBytes((int)fs.Length);

                    try
                    {
                        using (SqlContextDataContext con = new SqlContextDataContext())
                        {
                            tblUser user = con.tblUsers.First(x => x.pkUserId == UserId);
                            user.bytUserImage = bytes;
                            con.SubmitChanges();
                        }
                    }
                    catch (Exception err)
                    {
                        throw new ApplicationException(err.Message);
                    }
                }
            }
        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (this.Page.IsValid)
            {
                using (SqlContextDataContext context = new SqlContextDataContext())
                {
                    string UserName  = txtUserName.Text.Trim();
                    string UserEmail = txtUserEmail.Text.Trim();

                    int UserNameCount  = context.tblUsers.Where(x => x.strUserName == UserName).Count();
                    int UserEmailCount = context.tblUsers.Where(x => x.strEmail == UserEmail).Count();

                    if (UserNameCount == 0 && UserEmailCount == 0)
                    {
                        int UserId = 0;

                        tblUser NewUser = new tblUser
                        {
                            datDateRegistered = DateTime.Now,
                            strEmail          = txtUserEmail.Text.Trim(),
                            strPassword       = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassWord.Text.Trim(), "SHA1"),
                            strUserName       = txtUserName.Text.Trim(),
                        };


                        context.tblUsers.InsertOnSubmit(NewUser);
                        context.SubmitChanges();

                        UserId += NewUser.pkUserId;

                        lblRegisterSuccessful.Text      = "Registered Successfully!";
                        lblRegisterSuccessful.ForeColor = System.Drawing.Color.Green;

                        pnlRegisterIsSuccessful.Visible    = true;
                        pnlRegisterIsNotSuccessful.Visible = false;

                        UserInfo.InsertDefaultAvatar(UserId);
                    }
                    else if (UserNameCount == 1)
                    {
                        lblStatus.Text      = "User Name Already In User";
                        lblStatus.ForeColor = System.Drawing.Color.Red;
                        pnlRegisterIsNotSuccessful.Visible = true;
                    }
                    else
                    {
                        lblStatus.Text      = "User Email Already In User";
                        lblStatus.ForeColor = System.Drawing.Color.Red;
                        pnlRegisterIsNotSuccessful.Visible = true;
                    }
                }
            }
        }
Exemple #9
0
        private void InsertUserFavoriteNflTeam(int UserId, int FavoriteTeamId)
        {
            using (SqlContextDataContext context = new SqlContextDataContext())
            {
                tblUsersFavoriteNflTeam NewUsersFavoriteTeam = new tblUsersFavoriteNflTeam
                {
                    fkSportsTeam = FavoriteTeamId,
                    fkUserId     = UserId
                };

                context.tblUsersFavoriteNflTeams.InsertOnSubmit(NewUsersFavoriteTeam);
                context.SubmitChanges();
            }
        }
Exemple #10
0
            public void InsertPageView(int UserId, string BaseUrl, int QueryStringValue, bool IsTeamBet)
            {
                using (SqlContextDataContext c = new SqlContextDataContext())
                {
                    tblStatsPageVisit NewPageVisit = new tblStatsPageVisit
                    {
                        fkUserId            = UserId,
                        strBaseUrlVisited   = BaseUrl,
                        strQueryStringValue = QueryStringValue,
                        datDateTimeVisited  = DateTime.Now,
                        blnIsTeamBet        = IsTeamBet
                    };

                    c.tblStatsPageVisits.InsertOnSubmit(NewPageVisit);
                    c.SubmitChanges();
                }
            }
Exemple #11
0
        protected void fvPaymentInformation_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            FormView fv  = (FormView)sender;
            DataKey  key = fv.DataKey;
            string   txtAccountNumber = ((TextBox)fv.FindControl("txtAccountNumber")).Text;
            string   txtFirstName     = ((TextBox)fv.FindControl("txtFirstName")).Text;
            string   txtLastName      = ((TextBox)fv.FindControl("txtLastName")).Text;

            using (SqlContextDataContext con = new SqlContextDataContext())
            {
                tblUsersPaymentInformation pay = con.tblUsersPaymentInformations.SingleOrDefault(x => x.fkUserId == (int)Session["UserId"]);
                pay.strAccountNumber = txtAccountNumber.Trim();
                pay.strFirstName     = txtFirstName.Trim();
                pay.strLastName      = txtLastName.Trim();

                con.SubmitChanges();
            }
        }
Exemple #12
0
        protected void btnRecoverPassWord_Click(object sender, EventArgs e)
        {
            this.Page.Validate();

            if (this.Page.IsValid)
            {
                using (SqlContextDataContext context = new SqlContextDataContext())
                {
                    var results = from t in context.tblUsers
                                  where t.strEmail == txtEmail.Text
                                  select t;

                    if (results.Count() > 0)
                    {
                        foreach (var result in results)
                        {
                            Guid   guid         = Guid.NewGuid();
                            string TempPassWord = RandomPassWordGenerator(16);

                            tblCredentialsRecovery rec = new tblCredentialsRecovery
                            {
                                guiRecoveryGuid         = guid,
                                fkUserId                = result.pkUserId,
                                datResetRequestDateTime = DateTime.Now,
                                strTemporaryPassWord    = TempPassWord,
                                blnIsPassWordRecovery   = Convert.ToBoolean(rdoForgot.SelectedIndex)
                            };

                            context.tblCredentialsRecoveries.InsertOnSubmit(rec);
                            context.SubmitChanges();

                            SendPassWordResetLink(result.strEmail, result.strUserName, guid.ToString(), TempPassWord);

                            pnlEmailSent.Visible = true;
                        }
                    }
                    else
                    {
                        lblStatus.Text      = "Email Was Not Found";
                        lblStatus.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
        }
Exemple #13
0
        protected void btnPostToBulletin_Click(object sender, EventArgs e)
        {
            bool IsTeamBet = false;

            if (Request.QueryString["Type"] != null)
            {
                IsTeamBet = true;
            }

            int BetId;

            if (Request.QueryString["BetId"] != null && int.TryParse(Request.QueryString["BetId"], out BetId))
            {
                if (Session["UserId"] != null)
                {
                    tblParentBulletinBoard Board = new tblParentBulletinBoard
                    {
                        blnIsTeamBet            = IsTeamBet,
                        intBetId                = Convert.ToInt32(Request.QueryString["BetId"]),
                        datDateTimeCreated      = DateTime.Now,
                        intNumOfLikes           = 0,
                        strBoardMessage         = txtBulletinBoardMessage.Text.Trim(),
                        intUserIdWhoPostedBoard = (int)Session["UserId"],
                        intBoardAttachmentId    = 0
                    };

                    using (SqlContextDataContext c = new SqlContextDataContext())
                    {
                        c.tblParentBulletinBoards.InsertOnSubmit(Board);
                        c.SubmitChanges();
                    }

                    litBulletinBoard.Text = GetBulletinBoard(BetId, IsTeamBet).ToString();

                    ViewState["BulletinWasPosted"] = true;
                    pnlBulletinPosted.Visible      = true;
                }
                else
                {
                    pnlMustBeLoggedId.Visible   = true;
                    ViewState["MustBeLoggedIn"] = true;
                }
            }
        }
Exemple #14
0
            public void InsertSearchQuery(int UserId, bool IsPlayerBet, Guid guid, string EntityName, string StatArgument, string LogicArgument, decimal?ValueArgument)
            {
                using (SqlContextDataContext con = new SqlContextDataContext())
                {
                    tblStatsBetSearchQuery NewBetSearch = new tblStatsBetSearchQuery
                    {
                        fkUserId           = UserId,
                        IsPlayerBetSearch  = IsPlayerBet,
                        strEntityName      = EntityName,
                        strStatArgument    = StatArgument,
                        strLogicArgument   = LogicArgument,
                        strValueArgument   = ValueArgument,
                        datDateTimeCreated = DateTime.Now,
                        guidQuery          = guid
                    };

                    con.tblStatsBetSearchQueries.InsertOnSubmit(NewBetSearch);
                    con.SubmitChanges();
                }
            }
Exemple #15
0
        protected void btnResetPassWord_Click(object sender, EventArgs e)
        {
            Guid g;

            if (Guid.TryParse(Request.QueryString["guid"], out g))
            {
                using (SqlContextDataContext context = new SqlContextDataContext())
                {
                    var q = from t in context.tblCredentialsRecoveries
                            where t.guiRecoveryGuid.ToString() == g.ToString()
                            select t;

                    foreach (var r in q)
                    {
                        Page.Validate();

                        if (this.Page.IsValid)
                        {
                            if (txtTemporaryPassWord.Text.Trim() == r.strTemporaryPassWord)
                            {
                                tblUser user = context.tblUsers.SingleOrDefault(x => x.pkUserId == r.fkUserId);
                                user.strPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassWord.Text.Trim(), "SHA1");
                                context.SubmitChanges();

                                pnlPassWordReset.Visible = true;
                            }
                            else
                            {
                                lblStatus.Text      = "Invalid Temporary PassWord";
                                lblStatus.ForeColor = System.Drawing.Color.Red;
                            }
                        }
                    }
                }
            }
        }
Exemple #16
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();
                }
            }
        }