Exemplo n.º 1
0
        public async Task <HttpResponseMessage> SystemicBankTransfer(string BankFileString, string BankFileName, string id)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    string apiServiceUrl = SharedClass.ApiServerUrl + (Language == Settings.UserLanguage.English ? "en" : "ar") + "/api/HourlyContract/BankTransferStatementFile/" + id;

                    using (var content =
                               new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(System.Globalization.CultureInfo.InvariantCulture)))
                    {
                        byte[]       imageBytes = Convert.FromBase64String(BankFileString);
                        MemoryStream ms         = new MemoryStream(imageBytes, 0,
                                                                   imageBytes.Length);

                        content.Add(new StreamContent(ms), "BankFile", BankFileName);

                        using (
                            var message =
                                await client.PostAsync(apiServiceUrl, content))
                        {
                            var input = await message.Content.ReadAsStringAsync();

                            if (message.IsSuccessStatusCode)
                            {
                                var successMsg = new ResultMessageVM()
                                {
                                    Title              = Language == Settings.UserLanguage.Arabic ? "تم رفع ملف التحويل البنكي بنجاح" : "Bank Transfer Statement was uploaded successfully!",
                                    Message            = Language == Settings.UserLanguage.Arabic ? "تم رفع ملف التحويل البنكي بنجاح ... شكرا لكم" : "Bank Transfer Statement has been uploaded successfully... Thank you!",
                                    IsWithAutoRedirect = true,
                                    //UrlToRedirect = Url.Action("Details", "HourlyWorkers", new { id, lang = (Language == Settings.UserLanguage.Arabic ? "ar" : "en") }),
                                    RedirectTimeout = 10
                                };
                                return(OkResponse <ReturnData>(new ReturnData()
                                {
                                    State = true, Data = new { message = successMsg }
                                }));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            var failMsg = new ResultMessageVM()
            {
                Title              = Language == Settings.UserLanguage.Arabic ? "لم يتم رفع ملف التحويل البنكي" : "Bank Transfer Statement was not uploaded!",
                Message            = Language == Settings.UserLanguage.Arabic ? "لم يتم  رفع ملف التحويل البنكي بنجاح" : "Bank Transfer Statement was not uploaded!",
                IsWithAutoRedirect = false,
                //UrlToRedirect = Url.Action("Index", "Home", new { lang = Lang == Language.Arabic ? "ar" : "en" }),
                //RedirectTimeout = 10
            };

            return(OkResponse <ReturnData>(new ReturnData()
            {
                State = false, Data = new { message = failMsg }
            }));
        }
Exemplo n.º 2
0
        public ResultMessageVM IndividualFailBankTransferFileUploadMsg(string id)
        {
            var resultMsg = new ResultMessageVM()
            {
                Title   = DbRes.T("ProblemInUploadingBankTransfer", "Payment"),
                Message = DbRes.T("ProblemInUploadingBankTransferMsg", "Payment"),
            };

            return(resultMsg);
        }
        public async Task <ActionResult> PaymentStatus(string contractId)
        {
            var paymentMgr = new PaymentManager();

            string realCheckoutId = Request.QueryString["id"].ToString();

            string url           = string.Format("api/HourlyContract/{0}", contractId);
            var    contractToPay = await GetResourceAsync <ServiceContractPerHour>(url);

            if (paymentMgr.IsPaymentTransactionSucceededWithCheckoutId(realCheckoutId))
            {
                Dictionary <string, dynamic> paymentStatusResult = paymentMgr.StatuesRequestRequest(realCheckoutId);

                string requiredValue = paymentStatusResult["result"]["description"];
                string requiredCode  = paymentStatusResult["result"]["code"];//000.100.112 success

                //000.000.000   Live Transaction Success Code
                //Transaction succeeded
                if (requiredCode == "000.000.000" || requiredValue == "Transaction succeeded")
                {
                    var transaction = paymentMgr.AddSucceededPaymentTransaction(contractToPay, requiredCode, requiredValue);
                    if (transaction != null)
                    {
                        await CreateReceiptVoucher(contractToPay, transaction);

                        transaction.IsVoucherSaved = true;
                        paymentMgr.UpdatePaymentTransaction(transaction);
                    }

                    var resultMsg = new ResultMessageVM()
                    {
                        Title              = DbRes.T("SuccessPaymentOperation", "DalalResources"),
                        Message            = DbRes.T("PaymentOperationDoneSuccessfully", "DalalResources"),
                        IsWithAutoRedirect = true,
                        UrlToRedirect      = Url.Action("Index", "Home", new { lang = Lang == Language.Arabic ? "ar" : "en" }),
                        RedirectTimeout    = 10
                    };

                    return(View("Success", resultMsg));
                }
                else
                {
                    paymentMgr.AddFailedPaymentTransaction(contractToPay, requiredCode, requiredValue);
                    return(RedirectToAction("PaymentFailure", new { reason = requiredValue, id = contractId }));
                }
            }
            else
            {
                paymentMgr.AddFailedPaymentTransactionWithNoCheckoutId(contractToPay);
                return(RedirectToAction("PaymentFailure", new { id = contractId, reason = "There is not checkout id retrieved for this payment" }));
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult> SystemicBankTransfer(HttpPostedFileBase BankFile, string id)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    string apiServiceUrl = SharedClass.ApiServerUrl + (Lang == Language.English ? "en" : "ar") + "/api/HourlyContract/BankTransferStatementFile/" + id;

                    using (var content =
                               new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)))
                    {
                        content.Add(new StreamContent(BankFile.InputStream), "BankFile", BankFile.FileName);

                        using (
                            var message =
                                await client.PostAsync(apiServiceUrl, content))
                        {
                            var input = await message.Content.ReadAsStringAsync();

                            if (message.IsSuccessStatusCode)
                            {
                                var successMsg = new ResultMessageVM()
                                {
                                    Title              = DbRes.T("BankTransferIsUploaded", "DalalResources"),
                                    Message            = DbRes.T("UploadedBankTransferMsg", "DalalResources"),
                                    IsWithAutoRedirect = true,
                                    UrlToRedirect      = Url.Action("Details", "HourlyWorkers", new { id, lang = (Lang == Language.Arabic ? "ar" : "en") }),
                                    RedirectTimeout    = 10
                                };
                                return(View("Success", successMsg));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                IExceptionLogger logger = new DefaultExceptionLogger();
                logger.Log("Error", ex);
            }

            var failMsg = new ResultMessageVM()
            {
                Title              = DbRes.T("ProblemInUploadingBankTransfer", "DalalResources"),
                Message            = DbRes.T("ProblemInUploadingBankTransferMsg", "DalalResources"),
                IsWithAutoRedirect = false,
                //UrlToRedirect = Url.Action("Index", "Home", new { lang = Lang == Language.Arabic ? "ar" : "en" }),
                //RedirectTimeout = 10
            };

            return(View("Failure", failMsg));
        }
        public ActionResult UploadBankStatementDoneBefore()
        {
            var model = new ResultMessageVM()
            {
                Title              = DbRes.T("BankTransferIsUploadedBefore", "DalalResources"),
                Message            = DbRes.T("UploadedBankTransferBeforeMsg", "DalalResources"),
                IsWithAutoRedirect = true,
                UrlToRedirect      = Url.Action("Index", "Home", new { lang = Lang == Language.Arabic ? "ar" : "en" }),
                RedirectTimeout    = 10
            };

            return(View("Warning", model));
        }
        public ActionResult CancelledContract()
        {
            var model = new ResultMessageVM()
            {
                Title              = DbRes.T("ContractIsCancelled", "DalalResources"),
                Message            = DbRes.T("CancelledContractMsg", "DalalResources"),
                IsWithAutoRedirect = true,
                UrlToRedirect      = Url.Action("Index", "Home", new { lang = Lang == Language.Arabic ? "ar" : "en" }),
                RedirectTimeout    = 10
            };

            return(View("Failure", model));
            //return View("Success", model);
            //return View("Warning", model);
        }
        public ActionResult PaymentFailure(string id, string reason)
        {
            var msgHtml = String.Format(@"
                                        <div class='mt-3'>
                                            <a href='{0}' class='btn btn-lg btn-info'>
                                              {1}  <i class='fa fa-lock fa-lg'></i>&nbsp;
                                            </a>
                                        </div>
                                        <br />
                                        <p>
                                            <b>{2}</b>  : {3}
                                        </p>
                                        ", Url.Action("SystemicPayOnline", "DalalCrm", new { id, lang = (Lang == Language.Arabic ? "ar" : "en") }),
                                        DbRes.T("PayBtn", "Shared"), DbRes.T("Reason", "Shared"), reason);

            var resultMsg = new ResultMessageVM()
            {
                Title       = DbRes.T("FailedPaymentOperation", "DalalResources"),
                Message     = DbRes.T("PaymentOperationFailed", "DalalResources"),
                HtmlContent = msgHtml
            };

            return(View("Warning", resultMsg));
        }
Exemplo n.º 8
0
        public ResultMessageVM PaymentFailureMsg(string id, string reason, string urlToPayAgain)
        {
            var msgHtml = string.Format(@"
                                        <div class='mt-3'>
                                            <a href='{0}' class='btn btn-lg btn-info'>
                                              {1}  <i class='fa fa-lock fa-lg'></i>&nbsp;
                                            </a>
                                        </div>
                                        <br />
                                        <p>
                                            <b>{2}</b>  : {3}
                                        </p>
                                        ", urlToPayAgain,
                                        DbRes.T("PayBtn", "Shared"), DbRes.T("Reason", "Shared"), reason);

            var resultMsg = new ResultMessageVM()
            {
                Title       = DbRes.T("FailedPaymentOperation", "Payment"),
                Message     = DbRes.T("PaymentOperationFailed", "Payment"),
                HtmlContent = msgHtml
            };

            return(resultMsg);
        }
Exemplo n.º 9
0
        public ResultMessageVM IndividualSuccessBankTransferFileUploadMsg(string id, bool offline = false)
        {
            string redirectUrl;

            if (!offline)
            {
                redirectUrl = Url.Action("DomesticInvoice", "DomesticInvoice", new { lang = LangCode, id });
            }
            else
            {
                redirectUrl = Url.Action("Index", "Home", new { lang = LangCode });
            }

            var resultMsg = new ResultMessageVM()
            {
                Title              = DbRes.T("BankTransferIsUploaded", "Payment"),
                Message            = DbRes.T("UploadedBankTransferMsg", "Payment"),
                IsWithAutoRedirect = true,
                UrlToRedirect      = redirectUrl,
                RedirectTimeout    = 10
            };

            return(resultMsg);
        }
Exemplo n.º 10
0
        public ResultMessageVM IndividualSuccessOnlinePayment(string id, bool offline = false)
        {
            string redirectUrl;

            if (!offline)
            {
                redirectUrl = Url.Action("DomesticInvoice", "DomesticInvoice", new { lang = LangCode, id });
            }
            else
            {
                redirectUrl = Url.Action("Index", "Home", new { lang = LangCode });
            }

            var resultMsg = new ResultMessageVM()
            {
                Title              = DbRes.T("SuccessPaymentOperation", "Payment"),
                Message            = DbRes.T("PaymentOperationDoneSuccessfully", "Payment"),
                IsWithAutoRedirect = true,
                UrlToRedirect      = redirectUrl,
                RedirectTimeout    = 10
            };

            return(resultMsg);
        }
Exemplo n.º 11
0
        public ResultMessageVM IndividualPaidDomesticInvoice(string id, bool offline = false)
        {
            string urlToRedirectIfPaid;

            if (!offline)
            {
                urlToRedirectIfPaid = Url.Action("DomesticInvoice", "DomesticInvoice", new { lang = LangCode, id });
            }
            else
            {
                urlToRedirectIfPaid = Url.Action("Index", "Home", new { lang = LangCode });
            }

            var resultMsg = new ResultMessageVM()
            {
                Title              = DbRes.T("InvoiceIsPaidBefore", "Payment"),
                Message            = DbRes.T("InvoiceIsPaidBeforeMsg", "Payment"),
                IsWithAutoRedirect = true,
                UrlToRedirect      = urlToRedirectIfPaid,
                RedirectTimeout    = 10
            };

            return(resultMsg);
        }