public async Task <IActionResult> OnPost( [FromServices] AddToCart addToCart) { var stockAdded = await addToCart.DoAsync(CartViewModel); if (stockAdded) { return(RedirectToPage("Cart")); } else { // TODO: add a warning return(RedirectToPage("Error")); } }
public async Task <IActionResult> OnPostAsync([FromServices] AddToCart addToCart) { //ToDo: check whether any stock was selected var stockAddedToCart = await addToCart.DoAsync(CartViewModel); if (stockAddedToCart) { return(RedirectToPage("Cart")); } else { //ToDo: Redirect to warning return(Page()); } }
public async Task <IActionResult> AddOneAsync(int id, [FromServices] AddToCart addToCart) { var success = await addToCart.DoAsync(new AddToCart.Request() { StockId = id, Qty = 1, }); if (success) { return(Ok("Item was added successfully.")); } return(BadRequest("Failed to add to the cart.")); }
public async Task <bool> AddOneAsync(int productId) { var request = new AddToCart.Request { ProductId = productId, Quantity = 1 }; var success = await _addToCart.DoAsync(request); if (success) { return(true); } return(false); }
public async Task <IActionResult> OnPost([FromServices] AddToCart addToCart, int id) { var stockAdded = await addToCart.DoAsync(new AddToCart.Request { ProductId = id, Quantity = 1 }); if (stockAdded) { return(RedirectToPage("Cart")); } else { return(Page()); } }
public async Task <IActionResult> AddOne( Guid stockId, [FromServices] AddToCart addToCart) { var request = new AddToCart.Request { StockId = stockId, Quantity = 1 }; var success = await addToCart.DoAsync(request); if (success) { return(Ok("Item added to cart")); } return(BadRequest("Failed to add to cart")); }