protected void btnWithdraw_Click(object sender, EventArgs e)
    {
        //lblMSG.Text = string.Empty;
        if (Convert.ToDecimal(txtAmount.Text) >= 10)
        {
            UserWithdrawRequest userWithdrawRequest = new UserWithdrawRequest();

            userWithdrawRequest = LoadUserWithdrawRequest(userWithdrawRequest);
            using (TheFacade _facade = new TheFacade())
            {
                _facade.Insert<UserWithdrawRequest>(userWithdrawRequest);
                if (userWithdrawRequest.IID > 0)
                {
                    UserTransactionHistory userTransactionHistory = new UserTransactionHistory();
                    LoadUserTransactionHistory(userTransactionHistory, userWithdrawRequest);
                    _facade.Insert<UserTransactionHistory>(userTransactionHistory);
                    _facade.ZiaFacade.UpdateBalanceForWithdraw(CurrentUserID, userWithdrawRequest.Amount);
                }
            }
            Response.Redirect(Request.Url.ToString());
        }
        else
        {
            lblMSG.Text = "The Amount must be greater than or equal to 10";
        }
    }
    protected void lvConfirmation_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        if (e.CommandName == "DoConfirm")
        {

            using (TheFacade _facade = new TheFacade())
            {
                UserWithdrawRequest userWithdrawRequest = new UserWithdrawRequest();

                userWithdrawRequest = _facade.ZiaFacade.GetUserWithdrawRequestByIID(Convert.ToInt64(e.CommandArgument.ToString()));
                CurrentUserWithdrawID = userWithdrawRequest.IID;
                if (userWithdrawRequest.IID > 0)
                {
                    userWithdrawRequest = LoadUserWithdrawRequest(userWithdrawRequest);
                    _facade.Update<UserWithdrawRequest>(userWithdrawRequest);
                    UserTransactionHistory userTransactionHistory = _facade.ZiaFacade.GetUserTransactionHistoryByTransactionKey(userWithdrawRequest.TransactionKey);
                    userTransactionHistory.UserTransactionTypeID = Convert.ToInt32(EnumHelper.UserTransactionType.Withdraw);
                    userTransactionHistory.Status = Convert.ToInt32(EnumHelper.TransactionStatus.Completed);
                    _facade.Update<UserTransactionHistory>(userTransactionHistory);
                }
            }
        }
    }
 private UserWithdrawRequest LoadUserWithdrawRequest(UserWithdrawRequest userWithdrawRequest)
 {
     if (CurrentUserWithdrawID > 0)
     {
         userWithdrawRequest.TransactionStatus = Convert.ToInt32(EnumHelper.TransactionStatus.Completed);
         userWithdrawRequest.ComplitionDate = DateTime.Now;
     }
     return userWithdrawRequest;
 }
    private UserWithdrawRequest LoadUserWithdrawRequest(UserWithdrawRequest userWithdrawRequest)
    {
        if (CurrentNotificationID <= 0)
        {
            userWithdrawRequest.UserID = Convert.ToInt64(Session[GeneralConstant.LOGINUSERID].ToString());
            //userWithdrawRequest.UserID = 2;
            userWithdrawRequest.TransactionKey = Guid.NewGuid();
            userWithdrawRequest.TransactionStatus = Convert.ToInt32(EnumHelper.TransactionStatus.Pending);
            userWithdrawRequest.RequestDate = DateTime.Now;
            userWithdrawRequest.Amount = Convert.ToDecimal(txtAmount.Text);
        }
        else
        {
            userWithdrawRequest.TransactionStatus = Convert.ToInt32(EnumHelper.TransactionStatus.Completed);
            userWithdrawRequest.ComplitionDate = DateTime.Now;
        }

        return userWithdrawRequest;
    }
 private UserTransactionHistory LoadUserTransactionHistory(UserTransactionHistory userTransactionHistory, UserWithdrawRequest userWithdrawRequest)
 {
     if (CurrentNotificationID <= 0)
     {
         //userTransactionHistory.UserID = Convert.ToInt64(Session[GeneralConstant.LOGINUSERID].ToString());
         userTransactionHistory.UserID = Convert.ToInt64(Session[GeneralConstant.LOGINUSERID].ToString());
         userTransactionHistory.UserTransactionTypeID = Convert.ToInt32(EnumHelper.UserTransactionType.Withdraw);
         Decimal taxAmount = ((Convert.ToDecimal(txtAmount.Text) * 5) / 100);
         userTransactionHistory.Amount = Convert.ToDecimal(txtAmount.Text);
         userTransactionHistory.Date = DateTime.Now;
         userTransactionHistory.Description = string.Empty;
         userTransactionHistory.SponsorAmount = 0;
         userTransactionHistory.TAXAmount = taxAmount;
         userTransactionHistory.ActualAmount = Convert.ToDecimal(txtAmount.Text) - taxAmount;
         userTransactionHistory.TransactionKey = userWithdrawRequest.TransactionKey;
         userTransactionHistory.Status = Convert.ToInt32(EnumHelper.TransactionStatus.Pending);
     }
     else
     {
         userTransactionHistory.Status = Convert.ToInt32(EnumHelper.TransactionStatus.Completed);
     }
     return userTransactionHistory;
 }
Exemplo n.º 6
0
 public UserWithdrawRequest GetUserWithdrawRequestByIID(long id)
 {
     UserWithdrawRequest userWithdrawRequest = new UserWithdrawRequest();
     userWithdrawRequest = GetUserWithdrawRequestAll().Single(u => u.IID == id);
     return userWithdrawRequest;
 }