Exemple #1
0
        public IActionResult CheckOut()
        {
            double product_totalprice = 0;

            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("AccessDeniedPage", "Account"));
            }

            var cart = HttpContext.Session.GetJson <Cart>("Cart")?.Products ?? null;

            var ListshowCarts = new List <CartOrderModel>();

            CheckOutAndCartModel checkoutInformations = new CheckOutAndCartModel();


            foreach (var item in cart)
            {
                var model = new CartOrderModel();
                model.productImage = item.Product.ProductImage;
                model.productName  = item.Product.ProductName;
                model.productCode  = item.Product.ProductsId;
                model.unitPrice    = item.Product.NetProductPrice;
                if (item.ShippingPrice)
                {
                    model.unitPrice     = 0;
                    model.ShippingPrice = item.Product.ShippingPrice;
                    model.subTotal      = item.Product.ShippingPrice * item.Quantity;
                }
                else
                {
                    model.ShippingPrice = 0;
                    model.unitPrice     = item.Product.NetProductPrice;
                    model.subTotal      = item.Product.NetProductPrice * item.Quantity;
                }
                model.quantity = item.Quantity;
                ListshowCarts.Add(model);
                ViewBag.totalPriceForCart       = product_totalprice;
                checkoutInformations.CartOrders = ListshowCarts;
            }


            return(View(checkoutInformations));
        }
Exemple #2
0
        public IActionResult CheckOut(CheckOutAndCartModel model)
        {
            // try catch blguna al burayı  UNUTMA

            var cart = HttpContext.Session.GetJson <Cart>("Cart")?.Products ?? null;

            //    Dictionary<string, dynamic> responseData = new Dictionary<string, dynamic>();
            //    string data = "entityId=8a8294174b7ecb28014b9699220015ca" +
            //"&amount=92.00" +
            //"&currency=EUR" +
            //"&paymentType=DB";

            //bool res = GetCartResult(responseData, data);


            List <CartLine>      cartline             = new List <CartLine>();
            CheckOutAndCartModel checkoutInformations = new CheckOutAndCartModel();
            Random random = new Random();
            int    guid   = random.Next(100, 9999);


            //CheckoutModel Gereksiz sil
            var UserCartSaveInformation = new CheckOutLine();
            var userGeneralInformation  = new CheckOut();

            foreach (var item in cart)
            {
                cartline.Add(new CartLine
                {
                    CartLineId    = guid,
                    Product       = item.Product,
                    Quantity      = item.Quantity,
                    ShippingPrice = item.ShippingPrice
                });
                checkoutInformations.CartLines = cartline;
            }
            foreach (var item2 in checkoutInformations.CartLines)
            {
                UserCartSaveInformation.UserId         = User.FindFirstValue(ClaimTypes.NameIdentifier);
                UserCartSaveInformation.CheckOutNumber = guid;
                UserCartSaveInformation.ProductCodes  += item2.Product.ProductsId + " ) " + item2.Product.ProductName + " , ";
                UserCartSaveInformation.CheckOutDate   = DateTime.Now;
                UserCartSaveInformation.Quantity       = item2.Quantity;
                UserCartSaveInformation.Total          = 55;
            }
            uow.CheckOutLine.Add(UserCartSaveInformation);
            uow.SaveChanges();


            userGeneralInformation.UserId           = User.FindFirstValue(ClaimTypes.NameIdentifier);
            userGeneralInformation.CheckOutLineId   = guid;
            userGeneralInformation.FirstName        = model.CheckOutmodel.FirstName;
            userGeneralInformation.LastName         = model.CheckOutmodel.LastName;
            userGeneralInformation.Email            = model.CheckOutmodel.Email;
            userGeneralInformation.Telephone        = model.CheckOutmodel.Telephone;
            userGeneralInformation.Address1         = model.CheckOutmodel.Address1;
            userGeneralInformation.Address2         = model.CheckOutmodel.Address2;
            userGeneralInformation.City             = model.CheckOutmodel.City;
            userGeneralInformation.PostCode         = model.CheckOutmodel.PostCode;
            userGeneralInformation.PaymentMethod    = model.CheckOutmodel.PaymentMethod;
            userGeneralInformation.Total            = model.CheckOutmodel.Total;
            userGeneralInformation.IsApprovePayment = model.CheckOutmodel.IsApprovePayment; // <= odeme onaylanırsa True yada false donecek servisden gelen degere gore
            userGeneralInformation.Result           = "Hede";                               // servisten donen strin basılcak
            uow.CheckOut.Add(userGeneralInformation);
            uow.SaveChanges();

            return(View());
        }