Exemple #1
0
        //to show all the products from the cartlist
        public List <CartItems> GetCartItems()
        {
            OSBusinessLayer bll     = new OSBusinessLayer();
            var             lstcart = bll.GetCartItems();

            return(lstcart);
        }
Exemple #2
0
        //to get all the categories from the database
        public List <ProductCategory> GetAllCategories()
        {
            OSBusinessLayer bll  = new OSBusinessLayer();
            var             lstc = bll.GetAllCategories();

            return(lstc);
        }
Exemple #3
0
        //To get all the details of the product based on productid
        public Products GetProductDetailsById(int id)
        {
            OSBusinessLayer bll = new OSBusinessLayer();
            var             pro = bll.GetProductDetailsById(id);

            return(pro);
        }
Exemple #4
0
        //To get all the products in category based on Category name
        public List <Products> GetProductsByCategoryName(string cname)
        {
            OSBusinessLayer bll  = new OSBusinessLayer();
            var             lstc = bll.GetProductsByCategoryName(cname);

            return(lstc);
        }
Exemple #5
0
        //To get the products based on search by product name
        public List <Products> GetProductsByName(string productname)
        {
            OSBusinessLayer bll    = new OSBusinessLayer();
            var             lstpro = bll.GetProductsByName(productname);

            return(lstpro);
        }
Exemple #6
0
        /// <summary>
        /// This method to add items to cart
        /// </summary>
        /// <param name="lst">list as a parameter</param>
        //to post the product detail in the cartitem
        public HttpResponseMessage Post([FromBody] List <CartItems> lst)
        {
            HttpResponseMessage errRes = Request.CreateErrorResponse(HttpStatusCode.OK, "Record posted");

            try
            {
                OSBusinessLayer bll = new OSBusinessLayer();
                bll.AddToCart(lst);
            }
            catch (Exception ex)
            {
                errRes = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Record could not posted");
            }
            return(errRes);
        }
Exemple #7
0
        //to delete the product from the cart based on product id
        public HttpResponseMessage Delete(int id)
        {
            HttpResponseMessage errRes = Request.CreateErrorResponse(HttpStatusCode.OK, "Record deleted");

            try
            {
                OSBusinessLayer bll = new OSBusinessLayer();
                bll.DeleteFromCartById(id);
            }
            catch (Exception ex)
            {
                errRes = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Product id not found,could not delete");
            }
            return(errRes);
        }
        /// <summary>
        /// This method displays the products which are in cart list
        /// </summary>
        /// <param name="list">it is used to pass the cartlist whose record is to be selected</param>
        /// <returns>products are found</returns>
        public ActionResult ViewCart(string list)
        {
            var items = Session["cart_values"];

            if (items == null)
            {
                ViewBag.Message = "No products to display";
                items           = "0";
            }
            else
            {
                ViewBag.Message = "";
            }
            OSBusinessLayer obj        = new OSBusinessLayer();
            var             lstproduct = obj.ViewCart(items.ToString());

            return(View(lstproduct));
        }