Beispiel #1
0
        public IHttpActionResult PostCartTable(CartTable cartTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            db.CartTables.Add(cartTable);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CartTableExists(cartTable.CartID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cartTable.CartID }, cartTable));
        }
Beispiel #2
0
        public IHttpActionResult PutCartTable(int id, CartTable cartTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cartTable.CartID)
            {
                return(BadRequest());
            }

            db.Entry(cartTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CartTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        ////Data Methods

        /// <summary>
        /// Bind PostageTable Gridview
        /// Take the cart from session variable and bind CartTable gridview
        /// Columns 0 is made visible and hide because it correspond to the ID of whichis irrelevant for the user
        /// Update the value of invoice (Calcul())
        /// </summary>
        protected void BindData()
        {
            //Postages options
            BindPostages();

            //Cart content
            //Cart recuperation
            List <ProductSelectionDTO> cart = (List <ProductSelectionDTO>)(this.Session["Cart"]);

            CartTable.Columns[0].Visible = true;                //ID column visible for the Binding
            CartTable.DataSource         = getDataTableCart(cart);
            CartTable.DataBind();
            CartTable.Columns[0].Visible = false;
            Calcul();

            if (cart.Count == 0)
            {
                lblResult.Text       = ("Your cart is empty");
                AmountLabels.Visible = false;
            }
            else
            {
                AmountLabels.Visible = true;
            }
        }
Beispiel #4
0
        protected void deleteCart(object sender, EventArgs e)
        {
            int id     = Int32.Parse((sender as LinkButton).CommandArgument);
            int userID = Int32.Parse(Session["user"].ToString());

            CartController.doDeleteCart(id, userID);
            CartTable.DataBind();
            countGrandTotal();
        }
Beispiel #5
0
        public IHttpActionResult GetCartTable(int id)
        {
            CartTable cartTable = db.CartTables.Find(id);

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

            return(Ok(cartTable));
        }
Beispiel #6
0
        private void btnAddToCart_Click(object sender, EventArgs e)
        {
            DataRow row = CartTable.NewRow();

            row["ProductCode"] = searchLookUpMedicine.EditValue.ToString();
            row["ProductName"] = searchLookUpMedicine.Properties.View.GetFocusedDisplayText();
            row["Qty"]         = txtQuantity.Text;

            CartTable.Rows.Add(row);
            searchLookUpMedicine.Text = "";
            txtQuantity.Text          = "";
            searchLookUpMedicine.Focus();
        }
Beispiel #7
0
        public IHttpActionResult DeleteCartTable(int id)
        {
            CartTable cartTable = db.CartTables.Find(id);

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

            db.CartTables.Remove(cartTable);
            db.SaveChanges();

            return(Ok(cartTable));
        }
 public int AddToCart(int uid, int pid)
 {
     using (var context = new ShoppingELFEntities())
     {
         CartTable ct = new CartTable()
         {
             PID      = pid,
             UserID   = uid,
             Quantity = 1
         };
         context.CartTable.Add(ct);
         context.SaveChanges();
         return(ct.CartID);
     }
 }
Beispiel #9
0
        protected void checkout(object sender, EventArgs e)
        {
            int    userID         = Int32.Parse(Session["user"].ToString());
            string checkoutStatus = CartController.checkout(userID);

            if (checkoutStatus.Equals("success"))
            {
                Response.Redirect("CheckoutSuccess.aspx");
            }
            else if (checkoutStatus.Equals("empty"))
            {
                ErrorMessageLabel.Text = "Cart can't be empty";
            }
            CartTable.DataBind();
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        var qq = from a in ll.da.CartTables
                 where a.Uid == Convert.ToInt32(Session["uid"])
                 select a;

        foreach (CartTable k in qq)
        {
            CartTable ot = new CartTable();
            ot.Uid    = k.Uid;
            ot.Pid    = k.Pid;
            ot.Status = "u";
            ot.Qty    = k.Qty;
            ll.da.CartTables.InsertOnSubmit(ot);
        }
        ll.da.SubmitChanges();
    }
Beispiel #11
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["Uid"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }
        CartTable ct = new CartTable();

        ct.Uid = Convert.ToInt32(Session["Uid"]);
        ct.Pid = Convert.ToInt32(((Button)sender).CommandArgument);
        var q = (from a in dl.da.AddProductTables
                 where a.Id == Convert.ToInt32(((Button)sender).CommandArgument)
                 select a).FirstOrDefault();

        ct.Status      = "u";
        ct.TotalAmount = Convert.ToInt32(q.Price);
        ct.Status      = "u";
        dl.da.CartTables.InsertOnSubmit(ct);
        dl.da.SubmitChanges();
        Response.Redirect("~/Cart.aspx");
    }
Beispiel #12
0
    protected void AddProduct(string id, string itemcode, int productid, string description, decimal price, int qty, string imagefile, string imagefile2)
    {
        DataTable dt = new DataTable();

        dr                = CartTable.NewRow();
        dr["id"]          = id;
        dr["itemcode"]    = itemcode;
        dr["productid"]   = productid;
        dr["imagefile"]   = imagefile;
        dr["description"] = description;
        dr["qty"]         = qty;
        dr["price"]       = price;
        dr["Total"]       = price;
        dr["imagefile2"]  = imagefile2;

        CartTable.Rows.Add(dr);


        addCartItemToTable(dr);

        HttpContext.Current.Session["carttable"] = CartTable;
    }
 partial void UpdateCartTable(CartTable instance);
 partial void DeleteCartTable(CartTable instance);
Beispiel #15
0
 public CartPageSteps(IWebDriver driver)
 {
     CartPage  = new CartPage(driver);
     CartTable = new CartTable(driver);
 }
        public int AddFromCartToOrder(int uid)
        {
            using (ShoppingELFEntities context = new ShoppingELFEntities())
            {
                CartTable ct   = new CartTable();
                SizeTable st   = new SizeTable();
                UserTable user = new UserTable();
                user = context.UserTable.FirstOrDefault(m => m.UserID == uid);
                var cart      = context.CartTable.Where(m => m.UserID == uid).ToList();
                var cartitems = context.CartTable.Where(m => m.UserID == uid).ToList();
                if (cart.Count > 0)
                {
                    foreach (var i in cartitems)
                    {
                        st = context.SizeTable.FirstOrDefault(x => x.PID == i.PID);
                        if (st.productQuantity > 0)
                        {
                            OrderTable ot = new OrderTable()
                            {
                                UserID          = uid,
                                productBrand    = i.SizeTable.ProductTable.productBrand,
                                ProductName     = i.SizeTable.ProductTable.productName,
                                productPicture  = i.SizeTable.ProductTable.picture1,
                                productPrice    = i.SizeTable.productPrice,
                                productSize     = i.SizeTable.productSize,
                                productQuantity = i.Quantity,
                                PID             = i.PID,
                            };

                            st.productQuantity -= i.Quantity;
                            context.OrderTable.Add(ot);
                            context.SaveChanges();

                            ProductTable seller = new ProductTable();
                            seller = context.ProductTable.FirstOrDefault(x => x.ProductID == i.SizeTable.ProductID);


                            SoldTable soldt = new SoldTable()
                            {
                                SellerID        = seller.SellerID,
                                productName     = i.SizeTable.ProductTable.productName,
                                productBrand    = i.SizeTable.ProductTable.productBrand,
                                productPrice    = i.SizeTable.productPrice,
                                productQuantity = i.SizeTable.productQuantity,
                                productSize     = i.SizeTable.productSize,
                                productPicture  = i.SizeTable.ProductTable.picture1,
                                PID             = i.PID,
                                UserName        = user.email
                            };
                            context.SoldTable.Add(soldt);
                            context.SaveChanges();
                            //return 1;
                        }
                        else
                        {
                            return(2);
                        }
                    }
                    return(3);
                }
                else
                {
                    return(0);
                }
            }
        }
 partial void InsertCartTable(CartTable instance);