public async Task <IActionResult> Add(ProductViewModel productViewModel) { if (ModelState.IsValid) { var products = await _productServices.AddAsync(productViewModel); if (products) { TempData["Success"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString(); return(RedirectToAction("Index")); } ViewData["Error"] = _productLocalizer.GetLocalizedHtmlString("err_AddProductFailure"); ViewBag.CategoryId = new SelectList(_categoryServices.GetCategorys(), "Id", "CategoryName", productViewModel.CategoryId); ViewBag.BrandId = new SelectList(_brandServices.GetBrands(), "Id", "BrandName", productViewModel.BrandId); return(View(productViewModel)); } ViewBag.CategoryId = new SelectList(_categoryServices.GetCategorys(), "Id", "CategoryName", productViewModel.CategoryId); ViewBag.BrandId = new SelectList(_brandServices.GetBrands(), "Id", "BrandName", productViewModel.BrandId); Log.Error("Add Product Error"); return(View(productViewModel)); }
public async Task <bool> AddAsync([FromBody] Product product) { return(await _productServices.AddAsync(product)); }