public IActionResult Register()
        {
            IEnumerable <Category> categories = categoryRepository.GetAllCategories();

            ViewBag.Categories = SelectListItemHelpers.CreateNewListOfCategoryItems(categories);
            return(View());
        }
        public IActionResult Update(int id)
        {
            Product productToUpdate = productRepository.GetProduct(id);

            ViewBag.ImagesPaths = productToUpdate.Images.Select(i => i.Path).ToList();

            IEnumerable <Category> categories = categoryRepository.GetAllCategories();

            ViewBag.Categories = SelectListItemHelpers.CreateNewListOfCategoryItems(categories);

            return(View(productToUpdate));
        }
        public IActionResult Update(Product product)
        {
            var tempImagesPaths = new List <string>(Request.Form["imageFilePath"]);

            if (ModelState.IsValid)
            {
                productRepository.Update(product);

                List <string> permanentPaths = FileManager.MoveImagesToThePermanentFolder(tempImagesPaths, product.Id);
                imageRepository.Register(Image.CreateImageList(permanentPaths, product.Id));

                TempData["MSG_OK"] = Message.MSG_OK_002;
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.ImagesPaths = tempImagesPaths;

            IEnumerable <Category> categories = categoryRepository.GetAllCategories();

            ViewBag.Categories = SelectListItemHelpers.CreateNewListOfCategoryItems(categories);

            return(View());
        }