private CreateProductBrandAndCategoryAndDataViewModel CreateProductBrandAndCategoryAndDataViewModel(CategoryBrandViewModel brandCategoryViewModel, CreateProductBindingModel createProductBindingModel)
        {
            var productBrandAndCategoryAndDataViewModel = new CreateProductBrandAndCategoryAndDataViewModel {
                BrandCategoryViewModel = brandCategoryViewModel, CreateProductBindingModel = createProductBindingModel
            };

            return(productBrandAndCategoryAndDataViewModel);
        }
        public IActionResult Create(CreateProductBrandAndCategoryAndDataViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var categories = this.categoriesService.FindAllCategories();
                var brands     = this.brandsService.FindAllBrands();

                var productCategoryBrandViewModel = this.brandsService.CreateBrandCategoryViewModelByCategoriesAndBrands(categories, brands);
                model.BrandCategoryViewModel = productCategoryBrandViewModel;

                return(this.View(model));
            }

            var product = this.productsService.Create(model.CreateProductBindingModel, model.CreateProductBindingModel.Image);

            if (product == null)
            {
                var creationErrorViewModel = this.errorService.CreateCreateionErrorViewModel(CreationAlreadyExistsErrorMessage, HyperLinkForCreationError);

                return(this.RedirectToAction("CreationError", "Error", creationErrorViewModel));
            }

            return(this.Redirect("/Home/Index"));
        }