コード例 #1
0
        /// <summary>
        /// Edit product details
        /// </summary>
        /// <param name="id">The product Id</param>
        /// <returns>The product details view</returns>
        public ActionResult ProductEdit(int id)
        {
            MODEL.Product product = null;

            try
            {
                ProductService productService = new ProductService();

                //Get product details
                ProductVO productVO = productService.GetProductById(id);
                if (productVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.PRODUCT));
                }
                else
                {
                    product = new MODEL.Product(productVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("ProductDetails", product));
        }
コード例 #2
0
        /// <summary>
        /// Returns list of products
        /// </summary>
        /// <param name="param">The filter an other parameters</param>
        /// <returns>List of Products</returns>
        //// GET: /Administration/ProductList
        public ActionResult ProductList(MODEL.jQueryDataTableParamModel param)
        {
            try
            {
                ProductService   productService = new ProductService();
                List <ProductVO> productVOList  = productService.GetProductList();

                MODEL.Product product = new MODEL.Product();

                List <MODEL.Product> productList = new List <MODEL.Product>();
                foreach (var item in productVOList)
                {
                    productList.Add(new MODEL.Product(item));
                }

                //get the field on with sorting needs to happen and set the
                //ordering function/delegate accordingly.
                int sortColumnIndex  = Convert.ToInt32(Request["iSortCol_0"]);
                var orderingFunction = GetProductOrderingFunction(sortColumnIndex);

                var result = GetFilteredObjectsOrderByAscending(param, productList, orderingFunction);

                return(result);
            }
            catch (Exception e)
            {
                //ModelState.AddModelError("", e.Message);
                //return GetFilteredObjects(param, new List<MODEL.Product>(), null);
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
コード例 #3
0
        /// <summary>
        /// Save the Product
        /// </summary>
        /// <param name="model">model Object</param>
        /// <returns></returns>
        public ActionResult ProductSave(MODEL.Product model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //Get user id
                    int?           userId         = Session.GetUserId();
                    ProductService productService = new ProductService();
                    //ProductVO productVO = new ProductVO(model, userId);

                    ProductVO productVO = model.Transpose(userId);

                    productService.SaveProduct(productVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.PRODUCT));
                }
            }
            catch (ApplicationException e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
コード例 #4
0
 /// <summary>
 ///Create new Product
 /// </summary>
 /// <returns>The product details view</returns>
 // GET: /Administration/ProductCreate
 public ActionResult ProductCreate()
 {
     try
     {
         MODEL.Product product = new MODEL.Product();
         return(PartialView("ProductDetails", product));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeAndErrorResult(500, e.Message));
     }
 }