public async Task <IActionResult> CreateProduct(Product model) { try { //ProductModel modelVM = new ProductModel(); if (!ModelState.IsValid) { ViewBag.SuccessMessage = "false"; //return View(model); } else { //Product model empty //modelVM.Name = "dummy"; //Product result = new Product(); //result.Id = model.Id; //result.Name = model.Name; //result.Price = model.Price; //result.Qty = model.Qty; //result.Category = model.Category; //_context.Product.Add(result); //_context.SaveChanges(); // modelVM.Result = result; //List<Product> prodList = new List<Product>(); var productQry = await _context.Product.Where(x => x.Name == model.Name).FirstOrDefaultAsync(); if (productQry != null) { ViewBag.ErrorMessage = "Record Already Exists"; return(View()); } else { var createProd = await _detailService.CreateProductDetails(model); // ViewBag.SuccessMessage = "true"; return(RedirectToAction("ProductList", "Product")); } // return View(); } return(View()); } catch (Exception ex) { return(View("Error")); } }