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())); }
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())); }
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())); }
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())); }
public IActionResult OnGet( [FromServices] GetCart getCart) { Cart = getCart.Do(); return(Page()); }
public IActionResult GetCartComponent([FromServices] GetCart getCart) { var totalValue = getCart.Do() ?.Sum(x => x?.RealValue * x?.Quantity); return(PartialView("Components/Cart/Small", $"{totalValue}$")); }
public IActionResult GetCartMain([FromServices] GetCart getCart) { var cart = getCart.Do(); return(PartialView("_CartPartial", cart)); }
public IActionResult GetCartComponent([FromServices] GetCart getCart) { var totalValue = getCart.Do().Sum(x => x.RealValue * x.Qty); return(PartialView("Components/Cart/Small", $"${totalValue}")); }
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)); }
public IActionResult GetCart([FromServices] GetCart getCart) => Ok(getCart.Do());
public IEnumerable <GetCart.Response> GetCartProducts() => _getCart.Do();
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}₽")); }
public IEnumerable <GetCart.Response> GetCart([FromServices] GetCart getCart) { return(getCart.Do()); }
public IActionResult GetCartComponent([FromServices] GetCart getCart) { var total = getCart.Do().Sum(s => s.TheValue * s.Qty); return(PartialView("Components/Cart/Small", $"${total}")); }