public int UpdateUserOption(string ProcessorSku, string MainboarSku, int UserId)
        {
            UserCartModel userCart    = new UserCartModel();
            int           rowAffected = userCart.UpdateUserOption(ProcessorSku, MainboarSku, UserId);

            return(rowAffected);
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] UserCartModel userCartModel)
        {
            if (ModelState.IsValid)
            {
                await _userCartService.AddUserCart(userCartModel);

                return(Ok(userCartModel));
            }
            return(BadRequest(ModelState));
        }
コード例 #3
0
        public IHttpActionResult ConfirmToOrder(UserCartModel cartModel)
        {
            Order order = Manager.ConfirmCartToOrder(cartModel.UserId, cartModel.CartId);

            if (order == null)
            {
                return(NotFound());
            }
            return(Ok(order));
        }
コード例 #4
0
        public IHttpActionResult Confirm(UserCartModel userCart)
        {
            Order order = Manager.ConfirmCart(userCart.UserId, userCart.CartId);

            if (order == null)
            {
                return(NotFound());
            }

            return(Ok(order));
        }
コード例 #5
0
        public List <UserCartModel> GetCartProductList(List <int> products)
        {
            try
            {
                string productIDs = string.Join(", ", products);

                DBConnect  db  = new DBConnect();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT * FROM Products WHERE ProductID in (" + productIDs + ")";

                DataTable            tbl            = db.GetData(cmd);
                List <UserCartModel> userCartModels = new List <UserCartModel>();
                if (tbl != null)
                {
                    foreach (DataRow row in tbl.Rows)
                    {
                        UserCartModel userCartModel = new UserCartModel();
                        ProductModel  product       = new ProductModel();
                        product.productId   = Convert.ToInt32(row[0].ToString());
                        product.productName = row[1].ToString();
                        product.description = row[2].ToString();
                        product.price       = Convert.ToDecimal(row[3].ToString());
                        product.imagePath   = row[4].ToString();

                        userCartModel.product           = product;
                        userCartModel.quantity          = products.Count(x => x == product.productId);
                        userCartModel.productTotalPrice = userCartModel.product.price * userCartModel.quantity;


                        userCartModels.Add(userCartModel);
                    }
                }
                return(userCartModels);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #6
0
        public int CheckProductIsExist(int UserId, string SKU)
        {
            UserCartModel userCart = new UserCartModel();

            return(userCart.CheckProductIsExist(UserId, SKU));
        }
コード例 #7
0
        public int CheckUserChooseOrNot(int UserId)
        {
            UserCartModel userCart = new UserCartModel();

            return(userCart.CheckUserChooseOrNot(UserId));
        }
コード例 #8
0
        public async Task Edit(UserCartModel bookCartModel)
        {
            var sageCartEntities = Mapper.Map <UserCartModel, UserCart>(bookCartModel);

            _context.Entry(sageCartEntities).State = EntityState.Modified;
        }
コード例 #9
0
        public async Task Create(UserCartModel sageCartModel)
        {
            var sageCartEntities = Mapper.Map <UserCartModel, UserCart>(sageCartModel);

            await _context.UserCart.AddAsync(sageCartEntities);
        }
コード例 #10
0
        public async Task <IActionResult> Delete([FromBody] UserCartModel id)
        {
            await _userCartService.DeleteUserCart(id);

            return(Ok());
        }
コード例 #11
0
        public async Task EditUserCart(UserCartModel sageCartModel)
        {
            await _unitOfWork.UserCartRepository.Edit(sageCartModel);

            await _unitOfWork.SaveChanges();
        }
コード例 #12
0
        public async Task AddUserCart(UserCartModel sageCartModel)
        {
            await _unitOfWork.UserCartRepository.Create(sageCartModel);

            await _unitOfWork.SaveChanges();
        }