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" }));
                }
            }
        }
Exemplo n.º 2
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();
        }