예제 #1
0
        public async Task <IActionResult> CreateProduct(CreateProductBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            foreach (var image in model.Images)
            {
                if (image.ContentType != "image/png")
                {
                    ModelState.AddModelError("ImageTypeMismatch", "One of your images extension is incorrect.");
                    return(View());
                }
            }

            await _adminManager.CreateProductAsync(model);

            TempData["Success"] = "You successfully created new product.";
            return(RedirectToAction("CreateProduct"));
        }