public IActionResult OnGet([FromServices] GetCart getCart, [FromServices] GetCustomerInformation getCustomerInformation) { var cart = getCart.Exec(); if (cart.Count() == 0) { return(RedirectToPage("/Cart")); } var information = getCustomerInformation.Exec(); if (information == null) { if (_environment.IsDevelopment()) { CustomerInformation = new CustomerInformationDto { FirstName = "Toko", LastName = "Goshadze", Email = "*****@*****.**", PhoneNumber = "599744894", Address = "28 Amaghleba street", City = "Tbilisi", PostCode = "0105" } } ; return(Page()); } return(RedirectToPage("/Checkout/Payment")); }
// // GET: /Cart/ public ActionResult GetCart() { Users user = (Users)Session["User"]; if (user == null) { return(RedirectToAction("Index", "Home")); } var carts = db.Cart.Where(x => x.ClientId == user.Id).ToList(); List <GetCart> getCarts = new List <GetCart>(); ViewBag.TotalPrice = 0; foreach (var item in carts) { GetCart cart = new GetCart(); cart.Id = item.Id; cart.ProductId = item.ProductId; cart.ClientId = item.ClientId; cart.IsInCart = item.IsInCart; cart.Amount = item.Amount; cart.DatePurchased = item.DatePurchased; cart.Product = item.Product; cart.Users = item.Users; cart.FullPrice = cart.Amount * cart.Product.Price; ViewBag.TotalPrice += cart.FullPrice; getCarts.Add(cart); } return(View(getCarts)); }
public IActionResult GetCartComponent([FromServices] GetCart getCart) { var totalValue = getCart.Do().Sum(x => x.RealValue * x.Qty); return(PartialView("Components/Cart/Small", $"${totalValue}")); }
public IActionResult GetCartMain([FromServices] GetCart getCart) { var cart = getCart.Do(); return(PartialView("_CartPartial", cart)); }
public ActionResult ReduceCartItem(int id) { GetCart.Reduce(id); var responseDTO = _responseService.Create(true, ""); return(Json(Mapper.Map <ResponseVM>(responseDTO), JsonRequestBehavior.AllowGet)); }
public IActionResult OnGet( [FromServices] GetCart getCart) { Cart = getCart.Do(); return(Page()); }
public IActionResult OnGet() { Cart = new GetCart(HttpContext.Session, _context).Do(); Stock = new GetStock(_context).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 async Task <IActionResult> OnPostAsync( string paymentId, [FromServices] CreateOrder createOrder, [FromServices] GetCart getCart, [FromServices] PaymentIntentService paymentIntentService, [FromServices] ILogger <Payment> logger) { var userId = User.GetUserId(); var cartId = await getCart.Id(userId); if (cartId == 0) { logger.LogWarning($"Cart not found for {userId} with payment id {paymentId}"); return(RedirectToPage("/Checkout/Error")); } var payment = await paymentIntentService.CaptureAsync(paymentId); if (payment == null) { logger.LogWarning($"Payment Intent not found {paymentId}"); return(RedirectToPage("/Checkout/Error")); } var order = new Domain.Models.Order { StripeReference = paymentId, CartId = cartId, }; await createOrder.Do(order); return(RedirectToPage("/Checkout/Success", new { orderId = order.Id })); }
public async Task <IActionResult> AddToCart(AddToCart.Request Input) { Input.UserMark = GetCartUserMark(); var stockAdded = await new AddToCart(_ctx, _discounts).Do(Input); var cart = new GetCart(_ctx, _discounts).Do(GetCartUserMark()); return(PartialView("/Pages/Components/Cart/Small.cshtml", cart)); }
public IViewComponentResult Invoke([FromServices] GetCart getCart, string view = "Default") { if (view == "small") { var totalValue = _getCart.Do().Sum(x => x.RealValue * x.Qty); return(View(view, $"${totalValue}")); } return(View(_getCart.Do())); }
public IViewComponentResult Invoke(string view = "Huge") { if (view == "Smoll") { var totalValue = new GetCart(HttpContext.Session, _ctx).Do().Sum(x => x.ValueDec * x.Qty); return(View(view, $"$ {totalValue}")); } return(View(view, new GetCart(HttpContext.Session, _ctx).Do())); }
public IViewComponentResult Invoke(string view = "Default") { if (view == "Small") { var totalValue = new GetCart(HttpContext.Session, _ctx).Do().Sum(x => x.RealValue * x.Quantity); return(View(view, $"${totalValue}")); } return(View(view, new GetCart(HttpContext.Session, _ctx).Do())); }
//public Account account { get; set; } //public bool is30dayAccount { get; set; } public IActionResult OnGet() { Cart = new GetCart(_ctx, _discounts).Do(GetCartUserMark()); //var user = GetUserId(); //var accountId = _ctx.AccountUsers.FirstOrDefault(x => x.UserId == user); //account = _ctx.Accounts.FirstOrDefault(x => x.Id == accountId.AccountId); //is30dayAccount = account.ThirtyDayTermApproved; return(Page()); }
public async Task <IActionResult> GetCartForComponent([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.GetCartForComponent(userId))); }
public async Task <IActionResult> Cart() { // ilk ürün eklendiğinde kullanıcının kartı yoksa yeni cart oluşturacak var cart = new GetCart(); cart.UserName = User.Identity.Name; var result = await getCartService.HandleAsync(cart); return(View(result.Value)); }
public async Task <IActionResult> OnPostAsync( string paymentId, [FromServices] CreateOrder createOrder, [FromServices] GetCart getCart) { var order = new Domain.Models.Order { StripeReference = paymentId, CartId = await getCart.Id(User.GetUserId()), }; await createOrder.Do(order); return(RedirectToPage("/Checkout/Success", new { orderId = order.Id })); }
public async Task <IActionResult> UpdateCart([FromBody] UpdateCartQty.Request Input) { Input.UserMark = GetCartUserMark(); var stockadded = await new UpdateCartQty(_ctx).Do(Input); var cart = new GetCart(_ctx, _discounts).Do(GetCartUserMark()); var cartItems = await RenderViewAsync("Cart/_CartItems", cart, true); var cartSummary = await RenderViewAsync("Cart/_CartSummary", cart, true); var cartPartial = await RenderViewAsync("Cart/Small", cart, true); return(Ok(new { cartItems, cartSummary, cartPartial })); //return Ok(new { cartItems, cartSummary, qty = cart.Sum(x => x.Qty) }); }
public IViewComponentResult Invoke(string view = "Default") { var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var sessionId = GetSessionId(); if (view == "Small") { var cart = new GetCart(_ctx, _discounts).Do((userId, sessionId)); var totalValue = cart.Sum(x => x.Value * x.Qty); var totalItems = cart.Sum(x => x.Qty); //return View(view, $"{totalItems}"); return(View(view, cart)); } return(View(view, new GetCart(_ctx, _discounts).Do((userId, sessionId)))); }
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 async Task <IActionResult> OnGet( [FromServices] IOptionsMonitor <StripeSettings> optionsMonitor, [FromServices] GetCart getCart, [FromServices] PaymentIntentService paymentIntentService) { var userId = User.GetUserId(); StripeConfiguration.ApiKey = optionsMonitor.CurrentValue.SecretKey; var cart = await getCart.ByUserId(userId); if (cart == null || cart.Products.Count <= 0) { return(RedirectToPage("/Index")); } var paymentIntent = await paymentIntentService.CreateAsync(new PaymentIntentCreateOptions { CaptureMethod = "manual", Amount = cart.Total(), Currency = "gbp", ReceiptEmail = cart.Email, Shipping = new ChargeShippingOptions { Name = cart.Name, Phone = cart.Phone, Address = new AddressOptions { Line1 = cart.Address1, Line2 = cart.Address2, City = cart.City, Country = cart.Country, PostalCode = cart.PostCode, State = cart.State, }, }, }); ClientSecret = paymentIntent.ClientSecret; return(Page()); }
// Bu method tüm action lardan sonra çalışır. public override void OnActionExecuted(ActionExecutedContext context) { var searchProductCategoryCommand = new SearchProductCategories(); var sonuc = SearchProductCategoriesService.HandleAsync(searchProductCategoryCommand).Result; var cart = new GetCart(); cart.UserName = User.Identity.Name; var cartItems = new List <CartItem>(); var result = getCartService.HandleAsync(cart).Result; ViewBag.GetCartItems = (IList <CartItem>)result.Value.CartItems ?? cartItems; ViewBag.CartTotal = (decimal?)result.Value.CartTotal; ViewBag.Categories = sonuc.Value; base.OnActionExecuted(context); }
public async Task <IActionResult> OnGet( [FromServices] GetCart getCart, [FromServices] IWebHostEnvironment env) { var userId = User.GetUserId(); var cart = await getCart.Get(userId); if (cart.Products.Count <= 0) { return(RedirectToPage("/Index")); } Form = new CheckoutForm(); if (env.IsDevelopment()) { Form.Name = "test"; Form.Email = "*****@*****.**"; Form.Phone = "7845556789"; Form.Address1 = "Test"; Form.Address2 = ""; Form.City = "City"; Form.Country = "Country"; Form.PostCode = "QQ1 2RR"; Form.State = ""; } else if (cart.DeliveryInformationComplete) { Form.Name = cart.Name; Form.Email = cart.Email; Form.Phone = cart.Phone; Form.Address1 = cart.Address1; Form.Address2 = cart.Address2; Form.City = cart.City; Form.Country = cart.Country; Form.PostCode = cart.PostCode; Form.State = cart.State; } return(Page()); }
public async Task <ActionResult> AddToCart(int id) { var productDTO = await _productService.GetAsync(id); if (productDTO == null) { return(HttpNotFound()); } var productVM = Mapper.Map <ProductVM>(productDTO); GetCart.Add(productVM); Thread.Sleep(400); return(Json(new { IsSuccess = true, Quantity = GetCart.Count }, JsonRequestBehavior.AllowGet)); }
public IActionResult OnGet([FromServices] GetCustomerInformation getCustomerInformation, [FromServices] GetCart getCart) { var information = getCustomerInformation.Exec(); var totalValue = getCart.Exec().Sum(x => x.RealValue * x.Quantity); TotalValue = $"${totalValue}"; if (information == null) { return(RedirectToPage("/Checkout/CustomerInformation")); } var cart = getCart.Exec(); if (cart.Count() == 0) { return(RedirectToPage("/Cart")); } return(Page()); }
public async Task <IActionResult> OnPostAsync( string paymentId, [FromServices] CreateOrder createOrder, [FromServices] GetCart getCart, [FromServices] PaymentIntentService paymentIntentService) { var payment = await paymentIntentService.GetAsync(paymentId); if (payment == null) { //todo do some kinda notification that this went wrong. return(RedirectToPage()); } var order = new Domain.Models.Order { StripeReference = paymentId, CartId = await getCart.Id(User.GetUserId()), }; await createOrder.Do(order); return(RedirectToPage("/Checkout/Success", new { orderId = order.Id })); }
public Client.Query.OrderItem.Models.Cart Handle(GetCart query) { var ordersItens = from oi in _architectureContext.Orders .Include(x => x.Customer) .Include(x => x.OrderItems) from o in oi.OrderItems //where oi.Customer.Id == _user.UserId() select o; var result = ordersItens.Include(x => x.Product) .Select(x => new OrderItemIndex { Id = x.Id, Product = $"{x.Product.Name}, Price:{x.Product.Price}", Qtd = x.Qtd }).ToList(); return(new Client.Query.OrderItem.Models.Cart { OrderItens = result, TotalPrice = ordersItens.Sum(x => x.Product.Price * x.Qtd) }); }
public async Task <ActionResult <CartDto> > Get([FromRoute] GetCart query) => Single(await QueryAsync(query));
public CartViewComponent(GetCart getCart) { _getCart = getCart; }
public IActionResult GetCart([FromServices] GetCart getCart) => Ok(getCart.Do());