Exemplo n.º 1
0
    public int extractbet(decimal stake, decimal oddsum, string matchinfo, string skyteller, string recieptnumber, string phone)
    {
        int ret = 0;

        if (agent.checkcustomerphone(phone))
        {
            string customerusername = insertuser(phone);
        }
        if (!string.IsNullOrEmpty(recieptnumber))
        {
            users.Username = skyteller;
            users.getuser_info();
            if (users.balance >= stake)
            {
                //phone = users.resetphone(phone);
                //ret = admin.getbetid();
                admin.Username = skyteller;
                _username      = skyteller;
                _phone_no      = phone;
                _customerID    = users.getuser_info(phone, Login.USERNAME);
                //  int betid = admin.getbetid();
                admin.RecieptId = recieptnumber;
                _RecieptID      = recieptnumber;


                _RecieptID = recieptnumber;
                ret        = admin.getbetid();
                int games = 0;

                _setsize  = setsize;
                _betmoney = stake;
                int      count     = 0;
                string[] matchdata = splittoArray(matchinfo.Trim());
                if (matchdata.Length > 0)
                {
                    for (int i = 0; i < matchdata.Length; i++)
                    {
                        string   mtcinfo      = matchdata[i];
                        string[] playerchoice = SplitGameData(matchdata[i]);

                        if (playerchoice.Length == 3)
                        {
                            _matchno = playerchoice[0].Trim();
                            _bettype = playerchoice[1].Trim();
                            _oddname = playerchoice[2].Trim();

                            if ((!string.IsNullOrEmpty(_matchno)) && (!string.IsNullOrEmpty(_bettype)) && (!string.IsNullOrEmpty(_oddname)))
                            {
                                InsertPlayerBet();
                                count++;
                            }
                            else
                            {
                                return(0);
                            }
                        }
                    }
                    if (count > 0)
                    {
                        _setsize  = count;
                        _status   = 1;
                        _odd      = oddsum;
                        count     = updateSetDetails();
                        _AgentIds = skyteller;
                        if (count > 0)
                        {
                            if (UpdateagentonlineAccounts())
                            {
                                //successfull bet, send customer message.
                                //decimal win = Math.Round((stake * oddsum), 0);
                                //string msg = "You successfully betted through Agent: "+skyteller+". Your Receipt No. is "+recieptnumber+". Expected win is UGX "+win+". Thanks! www.trustbets.ug";
                                // string customermessage = customersuccessmessage(stake, Convert.ToInt32(recieptnumber), oddsum, recieptnumber);
                                //PhoneCustomer.SendVasMessage(customermessage, phone);
                                count = 100;/*
                                             * if (checkint())
                                             * {
                                             * string customermessage = customersuccessmessage(stake, Convert.ToInt32(recieptnumber), oddsum, recieptnumber);
                                             * sendcustomersms(customermessage, users.resetphone(users.resetphone(phone)));
                                             * }
                                             * return count;
                                             * */
                            }
                        }
                    }
                }

                return(count);
            }
            else
            {
                return(-1);
            }
        }

        return(ret);
    }