public IHttpActionResult changestatus(int userId, int id)
        {
            using (SleepingPartnermanagementTestingEntities dc = new SleepingPartnermanagementTestingEntities())
            {
                EWalletTransaction data = new EWalletTransaction();

                EWalletWithdrawalFund newuserdata = dc.EWalletWithdrawalFunds
                                                    .Where(a => a.WithdrawalFundId.Equals(id)).FirstOrDefault();

                var ewalletTransId = Convert.ToInt32(newuserdata.EwalletTransId.Value);
                EWalletTransaction ewalletCheck = dc.EWalletTransactions.Where(a => a.TransactionId.Equals(ewalletTransId)).FirstOrDefault();

                if (newuserdata != null)
                {
                    newuserdata.PaidDate = DateTime.Now;
                    newuserdata.IsActive = false;
                    newuserdata.IsPaid   = true;

                    data.TransactionSource = newuserdata.UserName + " : "
                                             + Common.Enum.AmountSource.Withdrawal.ToString() + " : " + newuserdata.WithdrawalFundDescription;
                    data.TransactionName            = Common.Enum.AmountDebitOrCredit.Credit.ToString();
                    data.AsscociatedMember          = newuserdata.UserId;
                    data.Amount                     = newuserdata.AmountPayble;
                    data.TransactionDate            = DateTime.Now;
                    data.Credit                     = true;
                    data.Debit                      = false;
                    data.UserId                     = newuserdata.UserId;
                    data.IsPackageBonus             = ewalletCheck.IsPackageBonus.Value;
                    data.PackageId                  = ewalletCheck.PackageId.Value;
                    data.IsMatchingBonus            = ewalletCheck.IsMatchingBonus.Value;
                    data.IsParentBonus              = ewalletCheck.IsParentBonus.Value;
                    data.IsWithdrawlRequestByUser   = false;
                    data.IsWithdrawlPaidByAdmin     = false;
                    data.IsWithdrawlRequestApproved = false;
                    data.AdminCredit                = false;
                    data.AdminDebit                 = false;
                    data.AdminTransactionName       = Common.Enum.AmountSource.Withdrawal.ToString();
                    dc.EWalletTransactions.Add(data);
                    dc.SaveChanges();

                    ewalletCheck.IsWithdrawlRequestApproved = true;
                    ewalletCheck.IsWithdrawlPaidByAdmin     = true;
                    dc.SaveChanges();

                    ModelState.Clear();
                    return(Ok(new { success = true, message = "success" }));
                }
                else
                {
                    return(Json(new { error = true, message = "failed" }));
                }
            }
        }
        public IHttpActionResult EWalletWithdrawalFund(EWalletWithdrawalFundModel model, int userId)
        {
            try
            {
                //  var userId = Convert.ToInt32(Session["LogedUserID"].ToString());
                using (SleepingPartnermanagementTestingEntities dc = new SleepingPartnermanagementTestingEntities())
                {
                    decimal amountcheck               = model.AmountPayble;
                    decimal withdrawalFundCharges     = 0;
                    int     payoutChargesPercent      = 0;
                    decimal payoutChargesPercentValue = 0;
                    decimal minimumPayout             = 0;
                    decimal amountAfterChargesDeduct  = 0;

                    var Debit = (from eWallTr in dc.EWalletTransactions
                                 where eWallTr.UserId == userId && eWallTr.Credit == false &&
                                 eWallTr.Debit == true && eWallTr.IsPackageBonus == true
                                 select eWallTr).ToList();
                    decimal DebitValue = Debit.Sum(x => x.Amount.Value);

                    var Credit = (from eWallTr in dc.EWalletTransactions
                                  where eWallTr.UserId == userId && eWallTr.Credit == true &&
                                  eWallTr.Debit == false && eWallTr.IsPackageBonus == true
                                  select eWallTr).ToList();
                    decimal CreditValue = Credit.Sum(x => x.Amount.Value);

                    decimal minVal = Math.Min(DebitValue, CreditValue);
                    decimal maxVal = Math.Max(DebitValue, CreditValue);

                    decimal Sum = maxVal - minVal;

                    EWalletWithdrawalFund newpckg = dc.EWalletWithdrawalFunds.Where(a => a.WithdrawalFundId.Equals(model.WithdrawalFundId)).FirstOrDefault();
                    NewUserRegistration   user    = dc.NewUserRegistrations.Where(a => a.UserId.Equals(userId)).FirstOrDefault();
                    if (user.IsPaidMember.Value == true)
                    {
                        EWalletPayoutConfig payoutconfig = dc.EWalletPayoutConfigs.FirstOrDefault();
                        minimumPayout = payoutconfig.MinimumPayout.Value;
                        if (model.AmountPayble >= minimumPayout)
                        {
                            if (model.AmountPayble <= Sum)
                            {
                                if (newpckg == null)
                                {
                                    payoutChargesPercent      = payoutconfig.PayoutChargesPercent.Value;
                                    payoutChargesPercentValue = (decimal)payoutChargesPercent / 100; //0.1

                                    withdrawalFundCharges    = model.AmountPayble * payoutChargesPercentValue;
                                    amountAfterChargesDeduct = model.AmountPayble - withdrawalFundCharges;

                                    EWalletWithdrawalFund newpckgadd = new EWalletWithdrawalFund();
                                    newpckgadd.UserName                  = user.Username;
                                    newpckgadd.AccountNumber             = user.AccountNumber; //auto
                                    newpckgadd.BankName                  = user.BankName;      //auto
                                    newpckgadd.WithdrawalFundMethod      = Common.Enum.PaymentSource.BankAccount.ToString();
                                    newpckgadd.AmountPayble              = amountAfterChargesDeduct;
                                    newpckgadd.WithdrawalFundDescription = model.WithdrawalFundDescription;
                                    newpckgadd.WithdrawalFundCharge      = withdrawalFundCharges; //auto
                                    newpckgadd.Country       = user.Country;
                                    newpckgadd.RequestedDate = DateTime.Now;
                                    newpckgadd.ApprovedDate  = null;
                                    newpckgadd.PaidDate      = null;
                                    newpckgadd.RejectedDate  = null;
                                    newpckgadd.IsActive      = true;
                                    newpckgadd.IsPending     = true;
                                    newpckgadd.IsApproved    = false;
                                    newpckgadd.IsPaid        = false;
                                    newpckgadd.IsRejected    = false;
                                    newpckgadd.UserId        = user.UserId;
                                    dc.EWalletWithdrawalFunds.Add(newpckgadd);
                                    dc.SaveChanges();
                                    ModelState.Clear();
                                    //    ViewBag.Message = "Successfully Done";
                                    return(Ok(new { success = true, message = "Successfully Done" }));
                                }
                                //else
                                //{
                                //    newpckg.TimePeriod = model.TimePeriod;
                                //    newpckg.MinimumPayout = model.MinimumPayout;
                                //    newpckg.PayoutChargesPercent = model.PayoutChargesPercent;
                                //    dc.SaveChanges();
                                //    model = null;
                                //    ViewBag.Message = "Successfully Edit";
                                //}
                            }
                            else
                            {
                                return(Ok(new { success = false, message = "Amount must be smaller than the eligible amount" }));
                            }
                        }
                        else
                        {
                            //this.AddNotification("Amount payable is less then minimum range", NotificationType.WARNING);
                            return(Ok(new { success = false, message = "Amount must be greater than the processing charges" }));
                            //return RedirectToAction("EWalletWithdrawalFund");
                        }
                    }
                    else
                    {
                        return(Ok(new { success = false, message = "You are not eligible for withdrawal. Kindly purchase your package." }));
                    }
                }
                //this.AddNotification("Value has bees saved", NotificationType.SUCCESS);
                return(Ok(new { success = true, message = "Successfully Done" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { success = false, message = "exception" }));
            }
            //return View();
        }
예제 #3
0
        public IHttpActionResult SendDirectSaleCommissionRequest(int transactionId)
        {
            using (SleepingPartnermanagementTestingEntities dc = new SleepingPartnermanagementTestingEntities())
            {
                EWalletTransaction ewallet = dc.EWalletTransactions
                                             .Where(a => a.TransactionId.Equals(transactionId)).FirstOrDefault();
                if (ewallet != null)
                {
                    if (ewallet.IsWithdrawlRequestByUser == false)
                    {
                        var userId = Convert.ToInt32(ewallet.UserId.Value);
                        NewUserRegistration   user       = dc.NewUserRegistrations.Where(a => a.UserId.Equals(userId)).FirstOrDefault();
                        EWalletWithdrawalFund newpckgadd = new EWalletWithdrawalFund();

                        if (user.IsVerify.Value == false)
                        {
                            return(Ok(new { info = true, message = "you are not eligible to withdrawal direct commission please complete and verify your profile" }));
                        }
                        else
                        {
                            //    TwilioClient.Init(SendSMSAccountSid, SendSMSAuthToken);
                            //    var message = MessageResource.Create(
                            //        body: "Sleeping partner portal alert. "
                            //        + " You Sent Withdrawal Request To Admin"
                            //        + " Your Withdrawal Amount is : " + ewallet.Amount
                            //        + " and request Date is : " + DateTime.Now + "."
                            //        + " Click on http://sleepingpartnermanagementportalrct.com ",
                            //        from: new Twilio.Types.PhoneNumber(SendSMSFromNumber),
                            //        to: new Twilio.Types.PhoneNumber(user.Phone)
                            //    );


                            //    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                            //    mail.From = new MailAddress("*****@*****.**");
                            //    mail.To.Add(user.Email);
                            //    mail.Subject = "Sleeping partner management portal";
                            //    mail.Body += "Sleeping partner portal alert." +
                            //                " You Sent Withdrawal Request To Admin" +
                            //                " Your Withdrawal Amount is : " + ewallet.Amount +
                            //                " and request Date is : " + DateTime.Now + "."
                            //                + " Click on http://sleepingpartnermanagementportalrct.com ";
                            //    mail.IsBodyHtml = true;
                            //    SmtpClient smtp = new SmtpClient();
                            //    smtp.Host = "sleepingpartnermanagementportalrct.com";
                            //    smtp.EnableSsl = true;
                            //    smtp.UseDefaultCredentials = false;
                            //    smtp.Credentials = new NetworkCredential("*****@*****.**", "Yly21#p8");
                            //    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                            //    smtp.Port = 25;
                            //    ServicePointManager.ServerCertificateValidationCallback =
                            //    delegate (object s, X509Certificate certificate,
                            //             X509Chain chain, SslPolicyErrors sslPolicyErrors)
                            //    { return true; };
                            //    smtp.Send(mail);

                            ewallet.IsWithdrawlRequestByUser   = true;
                            ewallet.IsWithdrawlPaidByAdmin     = false;
                            ewallet.IsWithdrawlRequestApproved = false;
                            dc.SaveChanges();

                            newpckgadd.UserName                  = user.Username;
                            newpckgadd.AccountNumber             = user.AccountNumber;
                            newpckgadd.BankName                  = user.BankName;
                            newpckgadd.WithdrawalFundMethod      = Common.Enum.PaymentSource.BankAccount.ToString();
                            newpckgadd.AmountPayble              = ewallet.Amount.Value;
                            newpckgadd.WithdrawalFundDescription = ewallet.TransactionSource;
                            newpckgadd.WithdrawalFundCharge      = 0;
                            newpckgadd.Country        = user.Country;
                            newpckgadd.RequestedDate  = DateTime.Now;
                            newpckgadd.ApprovedDate   = null;
                            newpckgadd.PaidDate       = null;
                            newpckgadd.RejectedDate   = null;
                            newpckgadd.IsActive       = true;
                            newpckgadd.IsPending      = true;
                            newpckgadd.IsApproved     = false;
                            newpckgadd.IsPaid         = false;
                            newpckgadd.IsRejected     = false;
                            newpckgadd.UserId         = user.UserId;
                            newpckgadd.EwalletTransId = ewallet.TransactionId;
                            dc.EWalletWithdrawalFunds.Add(newpckgadd);
                            dc.SaveChanges();

                            ModelState.Clear();
                            return(Ok(new { success = true, message = "Successfully Done" }));
                        }
                    }
                    else
                    {
                        return(Ok(new { info = true, message = "You already sended request" }));
                    }
                }
                else
                {
                    return(Ok(new { error = true, message = "unsuccessfully" }));
                }
            }
            //return View();
        }