public void addItemTest()
 {
     Cart testCart = new Cart();
     testCart = controller.addItem(new Animal( "parrot", 1234));
     Assert.IsNotNull(testCart);
     Assert.IsTrue(testCart.cartTotal > 0);
 }
        public bool AddProductToCart(Model.Cart c)
        {
            SqlConnection con = new SqlConnection(SqlCon.constring);

            con.Open();
            SqlCommand cmd = new SqlCommand("insert into cart values(@id,@uid,@pid,@pname,@pimage,@quantity,@amount,@status,@createdon)", con);

            cmd.Parameters.AddWithValue("@id", c.Cart_id);
            cmd.Parameters.AddWithValue("@uid", c.Uid);
            cmd.Parameters.AddWithValue("@pid", c.Pid);
            cmd.Parameters.AddWithValue("@pname", c.Pname);
            cmd.Parameters.AddWithValue("@pimage", c.Pimage);
            cmd.Parameters.AddWithValue("@quantity", c.Quantity);
            cmd.Parameters.AddWithValue("@amount", c.Amount);
            cmd.Parameters.AddWithValue("@status", c.Status);
            cmd.Parameters.AddWithValue("@createdon", c.Createdon);
            int cnt = cmd.ExecuteNonQuery();

            con.Close();
            if (cnt > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["productID"] == null)
     {
         Response.Redirect("~/AccessDenied.aspx");
     }
     DAO.Product dp = new DAO.Product();
     pid = int.Parse(Request.QueryString["productID"].ToString());
     Model.Cart c = new Model.Cart();
     if (pid > 0)
     {
         Model.Product p = dp.GetProductsCartById(pid);
         c.Cart_id   = int.Parse(Session["CartId"].ToString());
         c.Pid       = p.Pid;
         c.Pimage    = p.Pimage;
         c.Uid       = int.Parse(Session["UserId"].ToString());
         c.Pname     = p.Pname;
         c.Status    = "pending";
         c.Quantity  = 1;
         c.Amount    = p.Pprice;
         c.Createdon = DateTime.Now;
         Controller.Cart cc = new Controller.Cart();
         Response.Write(cc.AddToCartValidate(c));
         Response.Redirect("ShoppingCart.aspx");
     }
 }
        private void place()
        {
            Cart cart = new Cart(currentField);

            Field rail = new Rail('-');

            rail.Place(cart);
        }
        public void deleteItemTest()
        {
            List<Animal> testList = new List<Animal>();
            Animal a = new Animal( "parrot", 1234);
            testList.Add(a);
            Cart testCart = new Cart(testList);

            testCart = controller.deleteItem(a);
            Assert.IsTrue(testCart.cartTotal <= 0);
        }
Example #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            UserManager userManager = new UserManager();

            if (userManager.validateUserLogin())
            {
                int         bookId      = Convert.ToInt32((context.Request["bookId"]));
                BookManager bookManager = new BookManager();
                Model.Book  bookModel   = bookManager.GetModel(bookId);
                if (bookModel != null)
                {
                    int         userId      = ((Model.User)context.Session["userInfo"]).Id;
                    CartManager cartManager = new CartManager();
                    //Model.Book bookModel = bookManager.GetModel(bookId);
                    Model.Cart cartModel = cartManager.GetModel(userId, bookId);
                    if (cartModel != null)
                    {
                        cartModel.Count = cartModel.Count + 1;
                        cartManager.Update(cartModel);
                    }
                    else
                    {
                        Cart modelCart = new Cart();
                        modelCart.Count = 1;
                        modelCart.Book  = bookModel;
                        modelCart.User  = (User)context.Session["userInfo"];
                        cartManager.Add(modelCart);
                    }

                    context.Response.Write("Success");
                }
                else
                {
                    context.Response.Write("No Such Stuff");
                }

                context.Response.Write("Success");
            }
            else
            {
                context.Response.Write("Please Login");
            }
        }
        public bool AddToCartValidate(Model.Cart c)
        {
            bool valid = false;

            if (c.Cart_id != 0 & c.Pid != 0 & c.Uid != 0)
            {
                DAO.Cart dc = new DAO.Cart();
                if (dc.CheckProductInCart(c.Cart_id, c.Pid, c.Uid))
                {
                    valid = false;
                }
                else
                {
                    dc.AddProductToCart(c);
                    valid = true;
                }
            }
            return(valid);
        }
        private void tochar()
        {
            Ship ship = new Ship(currentField);
            Cart cart = new Cart(startpoint);

            EmptyField emptyField = new EmptyField();
            Dock dock = new Dock();
            Rail rail = new Rail('-');
            StartPoint startpointer = new StartPoint('A');
            Storage storage = new Storage();
            Switch switchje = new Switch('S');
            Water water = new Water();

            ship.ToChar();
            cart.ToChar();

            emptyField.ToChar();
            dock.ToChar();
            rail.ToChar();
            startpointer.ToChar();
            storage.ToChar();
            switchje.ToChar();
            water.ToChar();
        }
        public List <Model.Cart> GetCartsPaid(int userid, int cartid)
        {
            List <Model.Cart> cartList = new List <Model.Cart>();
            SqlDataAdapter    da       = new SqlDataAdapter("select * from cart where status='" + "paid" + "'" + " and uid=" + userid + " and cart_id=" + cartid, con);
            DataSet           userset  = new DataSet();

            da.Fill(userset, "Carts");
            for (int i = 0; i < userset.Tables["Carts"].Rows.Count; i++)
            {
                Model.Cart c = new Model.Cart();
                c.Cart_id   = int.Parse(userset.Tables["Carts"].Rows[i][0].ToString());
                c.Uid       = int.Parse(userset.Tables["Carts"].Rows[i][1].ToString());
                c.Pid       = int.Parse(userset.Tables["Carts"].Rows[i][2].ToString());
                c.Pname     = (userset.Tables["Carts"].Rows[i][3].ToString());
                c.Pimage    = (userset.Tables["Carts"].Rows[i][4].ToString());
                c.Quantity  = int.Parse(userset.Tables["Carts"].Rows[i][5].ToString());
                c.Amount    = double.Parse(userset.Tables["Carts"].Rows[i][6].ToString());
                c.Status    = userset.Tables["Carts"].Rows[i][7].ToString();
                c.Createdon = DateTime.Parse(userset.Tables["Carts"].Rows[i][8].ToString());

                cartList.Add(c);
            }
            return(cartList);
        }
Example #10
0
 public Transaction(Cart cart)
 {
     this.cart = cart;
 }
 private void move()
 {
     Cart cart = new Cart(startpoint);
     cart.MakeMove(cart.WayToMove());
 }
Example #12
0
 public void updateStock(Cart cart, string todo)
 {
 }