Example #1
0
        public ProductPanelInsertDTO GetCategoryList()
        {
            var categories = CategoryService.GetForMultiSelect();
            var dto        = new ProductPanelInsertDTO
            {
                CategoryMultiSelectDTO = categories
            };

            return(dto);
        }
 public IActionResult Insert(ProductPanelInsertDTO dto)
 {
     if (ModelState.IsValid)
     {
         var result = ProductService.Insert(dto);
         if (result)
         {
             return(RedirectToAction("ProductList"));
         }
         else
         {
             throw new ArgumentException();
         }
     }
     else
     {
         return(View("AddProduct", dto));
     }
 }
Example #3
0
        public bool Insert(ProductPanelInsertDTO dto)
        {
            bool result = false;
            //var imagePath = ImageExtension.SaveToCdn(dto.Img, CDNConfig.Cdn, CDNConfig.Path);
            var pr = new Product()
            {
                Name     = dto.Name,
                Price    = dto.Price,
                Quantity = dto.Quantity,
                //ImagePath = imagePath
            };

            int inserted = _repository.Insert(pr);

            if (inserted > 0)
            {
                result = true;
            }
            return(result);
        }
Example #4
0
        public bool Insert(ProductPanelInsertDTO dto)
        {
            bool result = false;

            var imagePath = ImageExtension.SaveTowwwroot(dto.Img, "Product");

            var pdlist = new List <ProductCategory>();

            if (dto.CategoryMultiSelectDTO.CategoryIds != null && dto.CategoryMultiSelectDTO.CategoryIds.Count > 0)
            {
                foreach (var categoryId in dto.CategoryMultiSelectDTO.CategoryIds)
                {
                    var pd = new ProductCategory
                    {
                        CategoryId = categoryId
                    };

                    pdlist.Add(pd);
                }
            }

            var pr = new Product()
            {
                Name            = dto.Name,
                Price           = dto.Price,
                Quantity        = dto.Quantity,
                ImagePath       = imagePath,
                ProductCategory = pdlist
            };

            int inserted = _repository.Insert(pr);

            if (inserted > 0)
            {
                result = true;
            }
            return(result);
        }