Beispiel #1
0
        public ActionResult EditPost(AdManageViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                else
                {
                    long     UrlId       = (long)TempData["AdId"];
                    AdManage objAdManage = adManageRepository.GetAdById(UrlId);
                    objAdManage.UpdateDate  = DateTime.Now.Date;
                    objAdManage.UpdatedBy   = Convert.ToInt32(Session["UserId"]);
                    objAdManage.Title       = model.Title;
                    objAdManage.Description = model.Description;
                    objAdManage.RegistAdId  = Convert.ToInt64(Session["UserId"]);
                    adManageRepository.Edit(objAdManage);
                    return(RedirectToAction("Index", "AdManage"));
                }
            }
            catch (Exception ex)
            {
            }
            return(View());
        }
Beispiel #2
0
 /// <summary>
 /// 添加或编辑物料信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static AdInfo Create(AdInfo model)
 {
     if (model.Id == 0)
     {
         int id = AdManage.Insert(model);
     }
     else
     {
         AdManage.Update(model);
     }
     return(model);
 }
        public ActionResult Purchase(string stripeEmail, string stripeToken, AdManageViewModel model)
        {
            AdManage objAdManage = new AdManage();
            var      result      = new JsonResult();

            int    selectedplan = Convert.ToInt32(TempData["PlanAmount"]);
            string planname     = Enum.GetName(typeof(CommanClass.Plans), selectedplan);
            int    planvalue    = (int)Enum.Parse(typeof(CommanClass.PlanType), planname.ToString());
            int    planamount   = selectedplan * 100;
            string FileName     = string.Empty;
            int    userid       = Convert.ToInt32(Session["UserId"]);
            var    customers    = new StripeCustomerService();
            var    charges      = new StripeChargeService();

            try
            {
                var RegisteredUser = registrationRepository.GetClientById(userid);

                if (!string.IsNullOrEmpty(stripeEmail))
                {
                    var customer = customers.Create(new StripeCustomerCreateOptions
                    {
                        Email       = stripeEmail,
                        SourceToken = stripeToken
                    });

                    var charge = charges.Create(new StripeChargeCreateOptions
                    {
                        Amount      = planamount,
                        Description = selectedplan.ToString(),
                        //Currency = "usd",
                        Currency   = "eur",
                        CustomerId = customer.Id
                    });

                    //Save Response in PaymentTransaction Table
                    PaymentTransaction payment = new PaymentTransaction()
                    {
                        RegistId                             = userid,
                        Customer_stripeEmail                 = stripeEmail,
                        Customer_Id                          = customer.Id,
                        Customer_stripeToken                 = stripeToken,
                        Customer_Created                     = customer.Created,
                        Customer_DefaultSourceId             = customer.DefaultSourceId,
                        Customer_InvoicePrefix               = customer.InvoicePrefix,
                        Customer_StripeResponse_RequestId    = customer.StripeResponse.RequestId,
                        Customer_StripeResponse_ResponseJson = customer.StripeResponse.ResponseJson,

                        Charge_Id     = charge.Id,
                        Charge_Amount = charge.Amount,
                        Charge_BalanceTransactionId = charge.BalanceTransactionId,
                        Charge_Created               = charge.Created,
                        Charge_CustomerId            = charge.CustomerId,
                        Charge_Description           = charge.Description,
                        Charge_FailureCode           = charge.FailureCode,
                        Charge_FailureMessage        = charge.FailureMessage,
                        Charge_Outcome_SellerMessage = charge.Outcome.SellerMessage,
                        Charge_Paid      = charge.Paid,
                        Charge_Source_Id = charge.Source.Id,
                        Charge_Status    = charge.Status,
                        Charge_StripeResponse_RequestId    = charge.StripeResponse.RequestId,
                        Charge_StripeResponse_ResponseJson = charge.StripeResponse.ResponseJson,
                        IsSuccess     = true,
                        Response      = "Complete",
                        PaymentMethod = (int)CommanClass.PaymentMethod.Stripe
                    };
                    _paymentRepository.AddPayment(payment);
                    //_paymentRepository.SaveAll();

                    //Insert stripe response information in PaymentTransaction table
                    //db.PaymentTransaction.Add(payment);
                    //db.SaveChanges();

                    RegisteredUser.PaymentStatus = true;
                    registrationRepository.Edit(RegisteredUser);

                    if (!string.IsNullOrEmpty(charge.FailureCode))
                    {
                        model.ResponseMessage = "Your subscription failed!!";
                        model.Paymentstatus   = CommanClass.PaymentStatus.Failed;
                        return(View(model));
                    }
                }
                //for zarinpal payment plugin
                else
                {
                    //Payment with Zarinpal Service reference.
                    string             authority = string.Empty;
                    int                payment_request_response = 0;
                    PaymentTransaction payment = new PaymentTransaction();
                    try
                    {
                        PaymentGatewayImplementationServicePortTypeClient request = new PaymentGatewayImplementationServicePortTypeClient();
                        Amount = PlanCalculate.CalculatePlanAmount(selectedplan);
                        payment_request_response = request.PaymentRequest(MerchantID, 120, "Test", "", "", ZarinpalCallbackURL, out authority);
                        if (payment_request_response > 0)
                        {
                            if (Request.Files[0].ContentLength > 0)
                            {
                                Guid FileNameGuid = Guid.NewGuid();
                                FileName = FileNameGuid.ToString() + ".html";
                                string _path = Path.Combine(Server.MapPath("~/AdHTML"), FileName);
                                Request.Files[0].SaveAs(_path);
                            }

                            objAdManage             = Mapper.Map <AdManageViewModel, AdManage>(model);
                            objAdManage.Addeddate   = DateTime.Now.Date;
                            objAdManage.RegistAdId  = userid;
                            objAdManage.UpdateDate  = DateTime.Now.Date;
                            objAdManage.UpdatedBy   = userid;
                            objAdManage.UploadFile  = FileName;
                            objAdManage.Description = model.Description;

                            adManageRepository.AddAd(objAdManage);
                            adManageRepository.SaveAll();

                            payment.IsSuccess = false;
                            payment.RegistId  = userid;
                            payment.Authority = authority;
                            payment.Payment_RequestResponse = payment_request_response;
                            payment.Charge_Amount           = Convert.ToInt32(Amount);
                            //Insert in Payment Table
                            Session["IsPaymentPrecessing"] = false;
                            _paymentRepository.InsertPaymentTransactionData(payment);
                            //Redirect to zarinpal gateway site for payment.
                            return(Redirect(ZarinpalPaymentURL + authority));
                        }
                    }
                    catch (Exception ex)
                    {
                        payment.Charge_Amount                = Convert.ToInt32(Amount);
                        payment.IsSuccess                    = false;
                        payment.RegistId                     = userid;
                        payment.Authority                    = authority;
                        payment.Payment_RequestResponse      = payment_request_response;
                        payment.PaymentRequest_ErrorResponse = ex.ToString();
                        _paymentRepository.InsertPaymentTransactionData(payment);
                        Session["PaymentStatus"]       = false;
                        Session["IsPaymentPrecessing"] = false;
                    }
                }

                //Insert in DB
                if (Request.Files[0].ContentLength > 0)
                {
                    //FileName = Convert.ToString(Session["UserId"]) + ".html";
                    Guid FileNameGuid = Guid.NewGuid();
                    FileName = FileNameGuid.ToString() + ".html";
                    string _path = Path.Combine(Server.MapPath("~/AdHTML"), FileName);
                    Request.Files[0].SaveAs(_path);
                }

                // AdManage objAdManage = new AdManage();
                objAdManage             = Mapper.Map <AdManageViewModel, AdManage>(model);
                objAdManage.Addeddate   = DateTime.Now;
                objAdManage.RegistAdId  = Convert.ToInt64(Session["UserId"]);
                objAdManage.UpdateDate  = DateTime.Now;
                objAdManage.UpdatedBy   = Convert.ToInt32(Session["UserId"]);
                objAdManage.UploadFile  = FileName;
                objAdManage.Description = model.Description;

                adManageRepository.AddAd(objAdManage);
                if (adManageRepository.SaveAll())
                {
                    Registration objRegisterUser = registrationRepository.GetClientById(userid);
                    objRegisterUser.PaymentStatus = true;
                    registrationRepository.Edit(objRegisterUser);
                    Session["PaymentStatus"] = true;
                    model.ResponseMessage    = "Your subscription succesfully!!";
                    model.Paymentstatus      = CommanClass.PaymentStatus.Sucess;
                    return(View(model));
                }
                else
                {
                    model.ResponseMessage    = "Your subscription failed!!";
                    model.Paymentstatus      = CommanClass.PaymentStatus.Failed;
                    Session["PaymentStatus"] = false;
                }
            }
            catch (Exception ex)
            {
                //result.Data = "Your subscription failed!! " + ex.Message.ToString();
                model.ResponseMessage    = "Your subscription failed!! " + ex.Message.ToString();
                model.Paymentstatus      = CommanClass.PaymentStatus.Failed;
                Session["PaymentStatus"] = false;
            }

            return(View(model));
        }
Beispiel #4
0
 /// <summary>
 /// 获得物料
 /// </summary>
 /// <param name="adId"></param>
 /// <returns></returns>
 public static AdInfo Get(int adId)
 {
     return(AdManage.Get(adId));
 }
Beispiel #5
0
 /// <summary>
 /// 获得没有分页的物料
 /// </summary>
 /// <param name="deliveryId"></param>
 /// <returns></returns>
 public static List <AdInfo> ListWithoutPage(int deliveryId)
 {
     return(AdManage.ListWithoutPage(deliveryId));
 }
Beispiel #6
0
 /// <summary>
 /// 物料列表
 /// </summary>
 /// <param name="setting"></param>
 /// <returns></returns>
 public static IPageOfList <AdInfo> List(AdSearchSetting setting)
 {
     return(AdManage.List(setting));
 }
Beispiel #7
0
        public ActionResult Create(AdManageViewModel model, HttpPostedFileBase file)
        {
            string filename     = string.Empty;
            Guid   filenameGuid = Guid.NewGuid();
            //string requesturl = HttpContext.Request.Url.AbsoluteUri.ToString();

            var requesturl = string.Format("{0}://{1}{2}",
                                           HttpContext.Request.Url.Scheme,
                                           HttpContext.Request.Url.Authority, Url.Content("~"));

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                try
                {
                    if (Request.Files[0].ContentLength > 0)
                    {
                        string _path = "";
                        //if (requesturl.Contains(domain_ijli) || requesturl.Contains("https://ijl.li/"))
                        if (requesturl.Contains(domain_ijli))
                        {
                            _path = string.Format(@"{0}AdHTML\\{1}.html", directorypath, filenameGuid.ToString());
                            Request.Files[0].SaveAs(_path);
                        }
                        else
                        {
                            //_path = @"C:\Inetpub\vhosts\aiim.li\httpdocs\UrlShotner\AdHTML\" + filenameGuid.ToString() + ".html";
                            _path = string.Format(@"{0}AdHTML\\{1}.html", directorypath, filenameGuid.ToString());
                            Request.Files[0].SaveAs(_path);
                        }
                    }

                    AdManage objAdManage = new AdManage();
                    objAdManage            = Mapper.Map <AdManageViewModel, AdManage>(model);
                    objAdManage.Addeddate  = DateTime.Now;
                    objAdManage.RegistAdId = Convert.ToInt64(Session["UserId"]);
                    objAdManage.UpdateDate = DateTime.Now;
                    objAdManage.UpdatedBy  = Convert.ToInt32(Session["UserId"]);
                    //objAdManage.UploadFile = Session["UserId"].ToString();
                    objAdManage.UploadFile = filenameGuid.ToString() + ".html";

                    adManageRepository.AddAd(objAdManage);

                    if (adManageRepository.SaveAll())
                    {
                        return(RedirectToAction("Index", "AdManage"));
                    }
                    else
                    {
                        return(View(model));
                    }
                }
                catch (Exception ex)
                {
                    //throw ex;
                    return(View(model));
                }
            }
        }