public IViewComponentResult Invoke(string view = "Default")
 {
     if (view == "Small")
     {
         var totalValue = _getCart.Do().Sum(x => x.RealValue * x.Qty);
         return(View(view, $"$ {totalValue}"));
     }
     return(View(view, _getCart.Do()));
 }
Beispiel #2
0
        public IViewComponentResult Invoke(string view = "Default")
        {
            if (view == "Small")
            {
                var total = _getCart.Do().Sum(s => s.TheValue * s.Qty);

                return(View(view, $"${total}"));
            }
            return(View(view, _getCart.Do()));
        }
Beispiel #3
0
 public IViewComponentResult Invoke(string view = "Default")
 {
     if (view == "Small")
     {
         var totalValue = getCart.Do().Sum(x => x.RealValue * x.Qty);
         return(View(view, $"{totalValue} ₺"));
     }
     //We can use this if we want to use different UI but same data
     return(View(view, getCart.Do()));
 }
Beispiel #4
0
 public IViewComponentResult Invoke(string view = "Default")
 {
     if (view == "Small")
     {
         var totalValue = _getCart.Do()
                          ?.Sum(x => x?.RealValue * x?.Quantity);
         return(View(view, $"{totalValue}$"));
     }
     return(View(view, _getCart.Do()));
 }
Beispiel #5
0
        public IActionResult OnGet(
            [FromServices] GetCart getCart)
        {
            Cart = getCart.Do();

            return(Page());
        }
Beispiel #6
0
        public IActionResult GetCartComponent([FromServices] GetCart getCart)
        {
            var totalValue = getCart.Do()
                             ?.Sum(x => x?.RealValue * x?.Quantity);

            return(PartialView("Components/Cart/Small", $"{totalValue}$"));
        }
Beispiel #7
0
        public IActionResult GetCartMain([FromServices] GetCart getCart)
        {
            var cart = getCart.Do();


            return(PartialView("_CartPartial", cart));
        }
Beispiel #8
0
        public IActionResult GetCartComponent([FromServices] GetCart getCart)
        {
            var totalValue = getCart.Do().Sum(x => x.RealValue * x.Qty);


            return(PartialView("Components/Cart/Small", $"${totalValue}"));
        }
Beispiel #9
0
        public async Task <IActionResult> GetCart([FromServices] GetCart getCart)
        {
            var userId = User?.Claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value;

            if (string.IsNullOrEmpty(userId))
            {
                return(BadRequest("Cookie Policy not accepted"));
            }

            return(Ok(await getCart.Do(userId)));
        }
        public async Task <IActionResult> Do(
            [FromServices] IOptionsMonitor <StripeSettings> optionsMonitor,
            [FromServices] GetCart getCart)
        {
            StripeConfiguration.ApiKey = optionsMonitor.CurrentValue.SecretKey;
            var userId  = User?.Claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value;
            var options = new SessionCreateOptions
            {
                PaymentMethodTypes = new List <string>
                {
                    "card",
                },
                ShippingAddressCollection = new SessionShippingAddressCollectionOptions
                {
                    AllowedCountries = new List <string>
                    {
                        "CA",
                        "GB",
                    },
                },
                LineItems = (await getCart.Do(userId, x => new SessionLineItemOptions
                {
                    Amount = x.Stock.Value,
                    Currency = "gbp",
                    Name = x.Stock.Product.Name,
                    Description = x.Stock.Description,
                    Quantity = x.Qty,
                })).ToList(),
                Mode       = "payment",
                SuccessUrl = "https://localhost:5001/payment/success",
                CancelUrl  = "https://localhost:5001/payment/canceled",

                Metadata = new Dictionary <string, string>
                {
                    { "user_id", userId },
                },
            };

            var service = new SessionService();
            var session = service.Create(options);

            return(Ok(session.Id));
        }
Beispiel #11
0
 public IActionResult GetCart([FromServices] GetCart getCart) => Ok(getCart.Do());
Beispiel #12
0
 public IEnumerable <GetCart.Response> GetCartProducts() => _getCart.Do();
Beispiel #13
0
 public IViewComponentResult Invoke(string view = "Default")
 {
     return(View(view, _getCart.Do()));
 }
        public IActionResult GetCartNav([FromServices] GetCart getCart)
        {
            string total = getCart.Do().Sum(x => x.RealValue * x.Qty).ToString();

            return(PartialView("_Small", $"{total:N2}₽"));
        }
Beispiel #15
0
 public IEnumerable <GetCart.Response> GetCart([FromServices] GetCart getCart)
 {
     return(getCart.Do());
 }
Beispiel #16
0
        public IActionResult GetCartComponent([FromServices] GetCart getCart)
        {
            var total = getCart.Do().Sum(s => s.TheValue * s.Qty);

            return(PartialView("Components/Cart/Small", $"${total}"));
        }