Beispiel #1
0
        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());
        }
Beispiel #2
0
 public DetailModel(GetListsFull getListsFull, UpdateList updateList)
 {
     this._getListsFull = getListsFull;
     this._updateList   = updateList;
 }
Beispiel #3
0
 public IActionResult Get([FromServices] GetListsFull getListsFull) =>
 Ok(getListsFull.Do(GetUserId()));
Beispiel #4
0
 public IndexModel(GetListsFull getListsFull, DeleteList deleteList)
 {
     this._getListsFull = getListsFull;
     this._deleteList   = deleteList;
 }