Ejemplo n.º 1
0
 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()));
 }
Ejemplo n.º 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()));
        }
Ejemplo n.º 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()));
 }
Ejemplo n.º 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()));
 }
Ejemplo n.º 5
0
        public IActionResult OnGet(
            [FromServices] GetCart getCart)
        {
            Cart = getCart.Do();

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

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


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


            return(PartialView("Components/Cart/Small", $"${totalValue}"));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 11
0
 public IActionResult GetCart([FromServices] GetCart getCart) => Ok(getCart.Do());
Ejemplo n.º 12
0
 public IEnumerable <GetCart.Response> GetCartProducts() => _getCart.Do();
Ejemplo n.º 13
0
 public IViewComponentResult Invoke(string view = "Default")
 {
     return(View(view, _getCart.Do()));
 }
Ejemplo n.º 14
0
        public IActionResult GetCartNav([FromServices] GetCart getCart)
        {
            string total = getCart.Do().Sum(x => x.RealValue * x.Qty).ToString();

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

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