public async Task <IActionResult> Product( [FromBody] AddToCart.Request request, [FromServices] AddToCart addToCart) { request.UserMark = GetCartUserMark(); return(Ok(addToCart.Do(request))); }
public async Task <IActionResult> Cart( int id, [FromServices] GetListsFull getListsFull, [FromServices] AddToCart addToCart, bool redirectToCheckout = false) { var mark = GetCartUserMark(); var list = getListsFull.Do(mark.userId).FirstOrDefault(x => x.Id == id); foreach (var product in list.Products) { await addToCart.Do(new AddToCart.Request { UserMark = mark, ProductId = product.Id, Qty = product.Qty == 0 ? 1 : product.Qty }); } if (redirectToCheckout) { return(RedirectToPage("/Checkout/Index")); } return(Ok()); }
public async Task <IActionResult> OnPost([FromServices] AddToCart addToCart) { var stockAdded = await addToCart.Do(CartViewModel); if (stockAdded) { return(RedirectToPage("Index")); } else { return(Page()); } }
public async Task <IActionResult> AddOne(int stockId, [FromServices] AddToCart addToCart) { var request = new AddToCart.Request { StockId = stockId, Qty = 1 }; var success = await addToCart.Do(request); if (success) { return(Ok("Item added to cart")); } return(BadRequest("Failed to add to cart")); }
public async Task <IActionResult> OnPost([FromServices] AddToCart addToCart) { var stockAdded = await addToCart.Do(CartViewModel); if (stockAdded) { return(RedirectToPage("Cart")); } else { //todo add warning msg return(RedirectToPage("Product")); } }
public async Task <IActionResult> AddOne(int stockId) { var request = new AddToCart.Request { StockId = stockId, Qty = 1 }; var addToCart = new AddToCart(HttpContext.Session, _ctx); var success = await addToCart.Do(request); if (success) { return(Ok("Item Added to cart")); } return(BadRequest("Failed")); }
public async Task <IActionResult> AddOne(int stockId, [FromServices] AddToCart addToCart) { var request = new AddToCart.Request { StockId = stockId, Qty = 1 }; var success = await addToCart.Do(request); if (success) { return(Ok("Product added.")); } return(BadRequest("Error adding product.")); }
public async Task <IActionResult> AddOne( int stockId, [FromServices] AddToCart addToCart) { var request = new AddToCart.Request { StockId = stockId, Qty = 1 }; var success = await addToCart.Do(request); if (success) { return(Ok("Добавлено")); } return(BadRequest("Не получилось добавить в карзину")); }
public async Task <IActionResult> AddOne( int stockId, [FromServices] AddToCart addToCart) { var request = new AddToCart.Request { StockId = stockId, Qty = 1 }; var success = await addToCart.Do(request); if (success) { return(Ok("Produkt dodany do koszyka")); } return(BadRequest("Nie udało się dodać produktu")); }
public async Task <IActionResult> Cart( int id, [FromServices] AddToCart addToCart) { var mark = GetCartUserMark(); var list = _quotesService.GetQuote(id); foreach (var product in list.QuoteProducts) { await addToCart.Do(new AddToCart.Request { UserMark = mark, ProductId = product.ProductId, Qty = product.Qty }); } return(Ok()); }