コード例 #1
0
        public async Task <IActionResult> EditCartItem(CartItemForSaler cartItemForSaler)
        {
            var cartItem = await _context.CartItems.Where(x => x.QR.Equals(cartItemForSaler.QR)).FirstOrDefaultAsync();

            if (cartItem != null)
            {
                try
                {
                    cartItem.Price                 = cartItemForSaler.Price;
                    cartItem.ProductId             = cartItemForSaler.ProductId;
                    cartItem.Quantity              = cartItemForSaler.Quantity;
                    _context.Entry(cartItem).State = EntityState.Modified;
                    await _context.SaveChangesAsync();

                    return(new JsonResult(new { message = "با موفقیت بروزرسانی شد", status = "1" }));
                }
                catch (Exception ex)
                {
                    return(new JsonResult(new { message = ex.Message.ToString() + ex.StackTrace.ToString(), status = "1" }));
                }
            }
            else
            {
                return(new JsonResult(new { message = "خطایی رخ داده است", status = "0" }));
            }
        }
コード例 #2
0
        public async Task <IActionResult> ProductSales(string qrCode)
        {
            var item = await _context.CartItems.Where(x => x.QR.Equals(qrCode)).FirstOrDefaultAsync();

            if (item != null)
            {
                var product = _context.Products.Find(item.ProductId);
                var data    = new CartItemForSaler()
                {
                    ProductId = item.ProductId,
                    Date      = item.Date,
                    Descrip   = product.Description,
                    discount  = product.Discount,
                    Price     = item.Price,
                    QR        = item.QR,
                    Quantity  = item.Quantity,
                    UserName  = item.UserName
                };
                return(new JsonResult(new { status = "1", result = data }));
            }
            else
            {
                return(new JsonResult(new { status = "0", message = "خظایی رخ داده است" }));
            }
        }