Ejemplo n.º 1
0
        public ActionResult FinalApproval(Guid CustomerId, string FirstName, string LastName, string Email, string Phone, string Address, string offerCode)
        {
            Customer  cust  = db.Customer.Find(CustomerId);
            OfferCard offer = db.OfferCards.FirstOrDefault(c => c.OfferCode == offerCode);

            if (offer == null)
            {
                ViewBag.ErrorOfferCard = "کد تخفیف اشتباه است";
                return(View());
            }
            bool isvalid = db.CustomerOffers.Any(c => c.CustomerId == CustomerId && c.OfferCardId == offer.Id);

            if (isvalid)
            {
                ViewBag.ErrorOfferCard = "شما یکبار از این کد تخفیف استفاده کرده اید لطفا کد تخفیف دیگری را وارد کنید";
                return(View());
            }
            cust.FirstName       = FirstName;
            cust.LastName        = LastName;
            cust.Email           = Email;
            cust.Phone           = Phone;
            cust.LangId          = CultureInfo.CurrentCulture.Name;
            cust.Address         = Address;
            db.Entry(cust).State = EntityState.Modified;
            if (db.SaveChanges() > 0)
            {
                return(Redirect($"/Payment/Index?id={CustomerId}&offerCode={offerCode}"));
            }

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            OfferCard offerCard = db.OfferCards.Find(id);

            db.OfferCards.Remove(offerCard);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit(OfferCard offerCard)
 {
     if (ModelState.IsValid)
     {
         db.Entry(offerCard).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(offerCard));
 }
Ejemplo n.º 4
0
        public ActionResult Create(OfferCard offerCard)
        {
            if (ModelState.IsValid)
            {
                db.OfferCards.Add(offerCard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(offerCard));
        }
Ejemplo n.º 5
0
        // GET: OfferCards/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OfferCard offerCard = db.OfferCards.Find(id);

            if (offerCard == null)
            {
                return(HttpNotFound());
            }
            return(View(offerCard));
        }
Ejemplo n.º 6
0
 public void ShowConfirmPurchasePanel(OfferCard offerCard)
 {
     currentOffer = offerCard;
     ConfirmPurchasedPanel.SetActive(true);
 }
Ejemplo n.º 7
0
        // GET: Payment
        public ActionResult Index(Guid id, string offerCode)
        {
            if (SessionParameters.Customer == null)
            {
                return(Redirect("/Customers/Signin"));
            }

            List <Basket> baskets = db.Basket.Where(c => c.CustomerId == SessionParameters.Customer.CustomerId && c.IsArchive == false).ToList();

            Order order = new Order
            {
                OrderId      = Guid.NewGuid(),
                SaveDate     = DateTime.Now,
                IsFinaly     = false,
                CurrentPrice = baskets.Sum(c => c.Product.PriceWithOff)
            };

            if (!string.IsNullOrEmpty(offerCode))
            {
                OfferCard offer   = db.OfferCards.FirstOrDefault(c => c.OfferCode == offerCode);
                bool      isvalid = db.CustomerOffers.Any(c => c.CustomerId == SessionParameters.Customer.CustomerId && c.OfferCardId == offer.Id);
                if (!isvalid)
                {
                    order.OfferCardId = offer.Id;
                    switch (offer.OfferType)
                    {
                    case Enums.OfferType.TwoByOne:
                        break;

                    case Enums.OfferType.percent:
                        order.CurrentPrice = order.CurrentPrice - (order.CurrentPrice * offer.OfferAmount / 100);
                        break;

                    case Enums.OfferType.Price:
                        order.CurrentPrice = order.CurrentPrice - Convert.ToDecimal(offer.OfferCode);
                        break;
                    }
                }
            }
            //order.CurrentPrice = 100;
            db.Order.Add(order);
            db.SaveChanges();

            System.Net.ServicePointManager.Expect100Continue = false;
            ZarinPal.PaymentGatewayImplementationServicePortTypeClient zp = new ZarinPal.PaymentGatewayImplementationServicePortTypeClient();
            int    Amount = Convert.ToInt32(order.CurrentPrice);
            string url    = "http://kookwatch.com/Payment/Verify?cusId=" + SessionParameters.Customer.CustomerId + "&orderid=" + order.OrderId + "";
            //var url = "http://*****:*****@kookwatch.com", "09120332214", url, out string Authority);

            if (Status == 100)
            {
                Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority);
                //Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + Authority);
            }
            else
            {
                ViewBag.Error = "Error : " + Status;
            }
            return(View());
        }