コード例 #1
0
 public List <Models_Winlose_List> RetrieveWinloseList()
 {
     try
     {
         var data = (from t1 in _db.MstWinlose
                     join t2 in _db.MstUserAccount on t1.MemberSrno equals t2.MemberSrno
                     select new Models_Winlose_List
         {
             MemberSrno = t1.MemberSrno,
             WinloseAmount = t1.WinloseAmount,
             StakeAmount = t1.StakeAmount,
             Vendor = t1.Vendor,
             Currency = t1.Currency,
             CreatedDateTime = t1.CreatedDateTime,
             Product = t1.Product,
             GameType = t1.GameType,
             LoginId = t2.LoginId,
         }).OrderByDescending(x => x.CreatedDateTime).ToList();
         return(data);
     }
     catch (Exception ex)
     {
         var new_error = new LogErrorSystem
         {
             Title           = "Retrieve Winlose List",
             Details         = ex.Message + "/" + ex.StackTrace,
             Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
             CreatedDateTime = DateTime.Now,
         };
         _db.LogErrorSystem.Add(new_error);
         _db.SaveChanges();
         return(null);
     }
 }
コード例 #2
0
 public List <MstSettings> RetrieveSettingsListing()
 {
     try
     {
         return(_db.MstSettings.ToList());
     }
     catch (Exception ex)
     {
         var new_error = new LogErrorSystem
         {
             Title           = "Retrieve Settings Listing",
             Details         = ex.Message + "/" + ex.StackTrace,
             Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
             CreatedDateTime = DateTime.Now,
         };
         _db.LogErrorSystem.Add(new_error);
         _db.SaveChanges();
         return(null);
     }
 }
コード例 #3
0
 public int RequestDepositPaymentGateway(long MemberSrno, string DepositUrl, string Merchant, string Currency, string Customer, string Reference, string Key, decimal Amount, string Note, string Datetime, string FrontUrl, string BackUrl, string Language, string Bank, string ClientIp)
 {
     try
     {
         var PaymentGatewayRequest = new LogRequestPaymentGateway
         {
             MemberSrno      = MemberSrno,
             DepositUrl      = DepositUrl,
             Merchant        = Merchant,
             Currency        = Currency,
             Customer        = Customer,
             Reference       = Reference,
             Key             = Key,
             Amount          = Amount,
             Note            = Note,
             Datetime        = Datetime,
             FrontUrl        = FrontUrl,
             BackUrl         = BackUrl,
             Language        = Language,
             Bank            = Bank,
             ClientIp        = ClientIp,
             CreatedDateTime = DateTime.Now,
         };
         _db.LogRequestPaymentGateway.Add(PaymentGatewayRequest);
         _db.SaveChanges();
         return(Models_General.SUCC_CREATE_PAYMENT_REQUEST);
     }
     catch (Exception ex)
     {
         var new_error = new LogErrorSystem
         {
             Title           = "Request Deposit Payment Gateway",
             Details         = ex.Message + "/" + ex.StackTrace,
             Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
             CreatedDateTime = DateTime.Now,
         };
         _db.LogErrorSystem.Add(new_error);
         _db.SaveChanges();
         return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
     }
 }
コード例 #4
0
        public string SaveImage(IFormFile Images, string WebPath, string ImageType, string BaseURL)
        {
            try
            {
                if (Images != null)
                {
                    string UploadPath = null;
                    string URL        = null;

                    switch (ImageType)
                    {
                    case "ANNOUNCEMENT":
                        UploadPath = Path.Combine(WebPath, "images/announcement");
                        URL        = BaseURL + "/announcement";
                        break;

                    case "BANNER":
                        UploadPath = Path.Combine(WebPath, "images/banner");
                        URL        = BaseURL + "/banner";
                        break;

                    case "TOPUP":
                        UploadPath = Path.Combine(WebPath, "images/topup");
                        URL        = BaseURL + "/topup";
                        break;
                    }

                    string ImageName = Guid.NewGuid().ToString() + Path.GetExtension(Images.FileName);
                    string FullPath  = Path.Combine(UploadPath, ImageName);
                    using (var fileStream = new FileStream(FullPath, FileMode.Create))
                    {
                        Images.CopyTo(fileStream);
                    }

                    return(URL + "/" + ImageName);
                }
                return(null);
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Save Image",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(null);
            }
        }
コード例 #5
0
        public async Task <Tuple <int, string> > LoginGame(string VendorCode, long MemberSrno, string browserType, string language, string gameCode)
        {
            try {
                var user_game_account = _db.MstUserGameAccount.Where(x => x.MemberSrno == MemberSrno).FirstOrDefault();


                var access_token = await _intergration.RetrievePlayerToken(user_game_account.GameId);

                if (access_token.Error >= 0)
                {
                    var game_url = await _intergration.OpenGame(access_token.Token, VendorCode, language, browserType, gameCode);

                    if (game_url.Success)
                    {
                        return(new Tuple <int, string>(Models_General.SUCC_OPEN_GAME, game_url.Result.Data));
                    }

                    return(new Tuple <int, string>(Models_General.ERR_CANNOT_LOGIN_GAME, ""));
                }


                return(new Tuple <int, string>(Models_General.ERR_GAME_TOKEN_NOT_FOUND, ""));
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Login Game",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(new  Tuple <int, string>(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR, ""));
            }
        }
コード例 #6
0
        public List <Models_User_Account_Downline_Listing> GetDownlineUsers(long UserId)
        {
            try
            {
                var trees = new List <Models_User_Downline_Listing>();
                var user  = _db.MstUser.Where(x => x.MemberSrno == UserId).FirstOrDefault();
                trees.Add(new Models_User_Downline_Listing
                {
                    UserId   = user.MemberSrno,
                    UplineId = user.UplineId,
                    Level    = 0,
                });

                trees.AddRange(GetDownlineUsersExcludeOwner(user.MemberSrno, 1));

                var result = (from t1 in trees
                              join t2 in _db.MstUserAccount on t1.UserId equals t2.MemberSrno
                              join t3 in _db.MstUserWallet on t1.UserId equals t3.MemberSrno
                              select new Models_User_Account_Downline_Listing
                {
                    UplineId = t1.UplineId,
                    Level = t1.Level,
                    UserId = t1.UserId,
                    LoginId = t2.LoginId,
                    CashCredit = t3.CashCredit,
                    TurnoverAmount = t3.TurnoverAmount
                }).OrderBy(x => x.Level).ToList();
                return(result);
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Retrieve User Downline Listing",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(null);
            }
        }
コード例 #7
0
        public async Task <Tuple <int, long> > UserRegisterNewAccount(string LoginID, string FullName, string Password, string Email, string Phonenumber, string CountryCode, string DOB, int Gender, string Upline)
        {
            using var dbContextTransaction = _db.Database.BeginTransaction();
            try
            {
                int temp       = 1;
                var RandomCode = "";
                do
                {
                    var tempcode = _common_services.GenerateRandomNumber(10);
                    if (IsRefcodeExist(tempcode))
                    {
                        temp = 1;
                    }
                    else
                    {
                        RandomCode = tempcode;
                        temp       = 0;
                    }
                }while (temp == 1);

                var gamelogin = "******" + RandomCode;

                if (Upline != null && !IsRefcodeExist(Upline))
                {
                    return(new Tuple <int, long>(Models_General.ERR_UPLINE_REFERCODE_NOT_EXIST, 0));
                }
                else if (IsUsernameExist(LoginID))
                {
                    return(new Tuple <int, long>(Models_General.ERR_USERNAME_EXIST, 0));
                }
                else if (IsPhoneExist(Phonenumber))
                {
                    return(new Tuple <int, long>(Models_General.ERR_PHONENUMBER_EXIST, 0));
                }
                else if (IsEmailExist(Email))
                {
                    return(new Tuple <int, long>(Models_General.ERR_EMAIL_EXIST, 0));
                }

                //This will be the main table that all references will be linked to this MemberSrno so we need it to be the first table to store in our database and get the MemberSrno
                var UserAccount = new MstUserAccount
                {
                    LoginId      = LoginID,
                    Password     = Password,
                    Status       = "ACTIVE",
                    AccountType  = "MEMBER",
                    GameRegister = 0
                };
                //Add this into database first so that we can retrive the MemberSrno
                _db.MstUserAccount.Add(UserAccount);
                _db.SaveChanges();

                //Register a new account into our system

                var UserDetails = new MstUser {
                };


                if (Upline != null && Upline != "")
                {
                    var UplineDetails = _db.MstUser.Where(x => x.RefCode.Equals(Upline)).FirstOrDefault();
                    var UplineAccount = _db.MstUserAccount.Where(x => x.MemberSrno.Equals(UplineDetails.MemberSrno)).FirstOrDefault();

                    UserDetails = new MstUser
                    {
                        MemberSrno   = UserAccount.MemberSrno,
                        Name         = FullName,
                        Email        = Email,
                        Phone        = Phonenumber,
                        Country      = CountryCode,
                        DoB          = DOB,
                        Gender       = Gender,
                        RegisterDate = DateTime.Now,
                        RefCode      = RandomCode,
                        Upline       = UplineAccount.LoginId,
                        UplineId     = UplineAccount.MemberSrno,
                    };
                }
                else
                {
                    UserDetails = new MstUser
                    {
                        MemberSrno   = UserAccount.MemberSrno,
                        Name         = FullName,
                        Email        = Email,
                        Phone        = Phonenumber,
                        Country      = CountryCode,
                        DoB          = DOB,
                        Gender       = Gender,
                        RegisterDate = DateTime.Now,
                        RefCode      = RandomCode,
                    };
                }

                var UserCashWallet = new MstUserWallet
                {
                    MemberSrno = UserAccount.MemberSrno,
                    CashCredit = 0
                };

                //Set defualt password for game account
                var _GamePassword = "******";

                var UserGameAccount = new MstUserGameAccount
                {
                    MemberSrno      = UserAccount.MemberSrno,
                    GamePassword    = _GamePassword,
                    GameId          = gamelogin,
                    CreatedDateTime = DateTime.Now,
                };
                var UserGameWallet = new MstUserGameWallet
                {
                    MemberSrno = UserAccount.MemberSrno,
                    GameId     = gamelogin,
                    GameCredit = 0,
                };

                //Call 998 API to create a agame account
                var result = await _intergration.CreateNewPlayer(gamelogin, FullName, Email, Phonenumber, DOB, _GamePassword, CountryCode, Gender);

                if (result.Error == 0)
                {
                    //API Successfully Created an Account from the thrid party side then only allow to create an account into our database
                    _db.MstUser.Add(UserDetails);
                    _db.MstUserWallet.Add(UserCashWallet);
                    _db.MstUserGameAccount.Add(UserGameAccount);
                    _db.MstUserGameWallet.Add(UserGameWallet);
                    UserAccount.GameRegister = 1;
                    await _db.SaveChangesAsync();

                    dbContextTransaction.Commit();

                    return(new Tuple <int, long>(Models_General.SUCC_CREATE_ACCOUNT, UserAccount.MemberSrno));
                }
                else
                {
                    _db.MstUser.Add(UserDetails);
                    _db.MstUserWallet.Add(UserCashWallet);
                    _db.MstUserGameAccount.Add(UserGameAccount);
                    _db.MstUserGameWallet.Add(UserGameWallet);
                    UserAccount.GameRegister = 2;
                    await _db.SaveChangesAsync();

                    dbContextTransaction.Commit();

                    return(new Tuple <int, long>(Models_General.SUCC_CREATE_ACCOUNT_WITHOUT_GAME_ACCOUNT, UserAccount.MemberSrno));
                }
            }
            catch (Exception ex)
            {
                dbContextTransaction.Rollback();


                var new_error = new LogErrorSystem
                {
                    Title           = "User Register New Account",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(new Tuple <int, long>(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR, 0));
            }
        }
コード例 #8
0
        public int CreateAnnoucement(string AdminID, string TitleEN, string TitleCN, string TitleMS, string AnnoucementContentEN, string AnnouncementContentCN, string AnnouncementContentMS, bool IsPublish, bool IsImagePublish, string WebPath, string BaseURL, IFormFile AnnoucementImg = null)
        {
            try
            {
                var imageurl = "";
                if (AnnoucementImg != null)
                {
                    var image_url = _image_services.SaveImage(AnnoucementImg, WebPath, "ANNOUNCEMENT", BaseURL);

                    if (!string.IsNullOrEmpty(image_url))
                    {
                        imageurl = image_url;
                    }
                }

                var new_announcement = new MstAnnouncement
                {
                    TitleEn = TitleEN,
                    TitleCn = TitleCN,
                    TitleMs = TitleMS,
                    AnnouncementContentEn = AnnoucementContentEN,
                    AnnouncementContentCn = AnnouncementContentCN,
                    AnnouncementContentMs = AnnouncementContentMS,
                    IsPublish             = IsPublish,
                    IsImagePublish        = IsImagePublish,
                    AnnouncementImagePath = imageurl,
                    LastUpdateBy          = AdminID,
                    LastModifiedDate      = DateTime.Now,
                    CreatedDateTime       = DateTime.Now,
                };
                _db.MstAnnouncement.Add(new_announcement);
                _db.SaveChanges();

                return(Models_General.SUCC_ADMIN_CREATE_ANNOUNCEMENT);
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Create Announcement",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
            }
        }
コード例 #9
0
        public int MemberAddNewBank(long MemberSrno, long BankSrno, string BankAccountHolderName, string BankCardNo)
        {
            try
            {
                var BankFound = _db.MstBank.Where(x => x.Srno == BankSrno).FirstOrDefault();

                if (BankFound != null)
                {
                    var UserBankDetails = new MstUserBank
                    {
                        MemberSrno        = MemberSrno,
                        BankSrno          = BankFound.Srno,
                        BankAccountHolder = BankAccountHolderName,
                        BankCardNo        = BankCardNo,
                        Status            = "ACTIVE",
                        CreatedDateTime   = DateTime.Now,
                    };
                    _db.MstUserBank.Add(UserBankDetails);
                    _db.SaveChanges();

                    return(Models_General.SUCC_MEMBER_ADD_BANK);
                }
                else
                {
                    return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
                }
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Member Add Bank",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
            }
        }
コード例 #10
0
 public int MemberRequestTopupWithOnlineBanking(long MemberSrno, long AdminBankSrno, decimal TopupAmount, IFormFile TopupImageProof, string TransactionReferenceNumber, string WebPath, string BaseURL, string Currency)
 {
     try
     {
         var CurrentAdminBank = _db.MstAdminBank.Where(x => x.Srno == AdminBankSrno).FirstOrDefault();
         if (CurrentAdminBank != null)
         {
             var CurrentMstBank = _db.MstBank.Where(x => x.Srno == CurrentAdminBank.BankSrno).FirstOrDefault();
             if (CurrentMstBank != null)
             {
                 var image_url = _image_services.SaveImage(TopupImageProof, WebPath, "TOPUP", BaseURL);
                 if (!string.IsNullOrEmpty(image_url))
                 {
                     var TopupRequest = new MstTopUp
                     {
                         MemberSrno                 = MemberSrno,
                         WalletType                 = "CASH WALLET",
                         TopupAmount                = TopupAmount,
                         TopupImageProof            = image_url,
                         TransactionReferenceNumber = TransactionReferenceNumber,
                         Currency          = Currency,
                         Status            = 0,
                         RequestDate       = DateTime.Now,
                         BankCode          = CurrentMstBank.BankCode,
                         BankName          = CurrentMstBank.BankName,
                         BankAccountHolder = CurrentAdminBank.BankAccountHolder,
                         BankAccountNumber = CurrentAdminBank.BankCardNo,
                         TransactionType   = 0
                     };
                     _db.MstTopUp.Add(TopupRequest);
                     _db.SaveChanges();
                     return(Models_General.SUCC_CREATE_REQUEST_TOPUP);
                 }
                 else
                 {
                     return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
                 }
             }
             else
             {
                 return(Models_General.ERR_BANK_INFO_NOT_MATCH);
             }
         }
         else
         {
             return(Models_General.ERR_ADMIN_BANK_NOT_FOUND);
         }
     }
     catch (Exception ex)
     {
         var new_error = new LogErrorSystem
         {
             Title           = "Member Request Topup With Online Banking",
             Details         = ex.Message + "/" + ex.StackTrace,
             Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
             CreatedDateTime = DateTime.Now,
         };
         _db.LogErrorSystem.Add(new_error);
         _db.SaveChanges();
         return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
     }
 }
コード例 #11
0
        public Tuple <int, MstUserWallet> GetUserWallet(long MemberSrno)
        {
            try
            {
                var result = _db.MstUserWallet.Where(x => x.MemberSrno.Equals(MemberSrno)).FirstOrDefault();

                if (result != null)
                {
                    return(new Tuple <int, MstUserWallet>(0, result));
                }
                else
                {
                    return(new Tuple <int, MstUserWallet>(Models_General.ERR_USER_NOT_FOUND, null));
                }
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Retrieve User Wallet",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(new Tuple <int, MstUserWallet>(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR, null));
            }
        }
コード例 #12
0
        public int MemberRequestWithdrawalOnlineBanking(long _MemberSrno, decimal WithdrawalAmount, long MemberBankSrno, string Currency)
        {
            try
            {
                var UserBankDetails = _db.MstUserBank.Where(x => x.Srno == MemberBankSrno).FirstOrDefault();

                if (UserBankDetails != null)
                {
                    var BankDetails = _db.MstBank.Where(x => x.Srno == UserBankDetails.BankSrno).FirstOrDefault();

                    if (BankDetails != null)
                    {
                        var WithdrawalRequest = new MstWithdraw
                        {
                            MemberSrno        = _MemberSrno,
                            BankName          = BankDetails.BankName,
                            BankCardNo        = UserBankDetails.BankCardNo,
                            BankAccountHolder = UserBankDetails.BankAccountHolder,
                            BankCode          = BankDetails.BankCode,
                            Status            = 0,
                            RequestDate       = DateTime.Now,
                            WithdrawAmount    = WithdrawalAmount,
                            TransactionType   = 0,
                            Currency          = Currency,
                        };

                        var CurrentUserWalletInfo = _db.MstUserWallet.Where(x => x.MemberSrno == _MemberSrno).FirstOrDefault();

                        if (WithdrawalAmount > CurrentUserWalletInfo.CashCredit)
                        {
                            return(Models_General.ERR_WALLET_CREDIT_INSUFFICIENT);
                        }

                        if (CurrentUserWalletInfo.TurnoverAmount > 0)
                        {
                            return(Models_General.ERR_WALLET_TURNOVER_CLEAR);
                        }

                        CurrentUserWalletInfo.CashCredit             = CurrentUserWalletInfo.CashCredit - WithdrawalAmount;
                        CurrentUserWalletInfo.PendingWithdrawAmount += WithdrawalAmount;

                        _db.MstWithdraw.Add(WithdrawalRequest);
                        _db.SaveChanges();
                        return(Models_General.SUCC_CREATE_REQUEST_WITHDRAWAL);
                    }
                    else
                    {
                        return(Models_General.ERR_BANK_INFO_NOT_MATCH);
                    }
                }
                return(Models_General.ERR_BANK_INFO_NOT_MATCH);
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Member Request Withdrawal Online Banking",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
            }
        }