public ActionResult Create(ProductList product) { if (product.IsDuplicate(i => i.ProductName)) { this.ModelState.AddModelError(string.Empty, "Duplicate products"); } if (this.ModelState.IsValid) { this.productService.Add(product.Where(i => i.ProductId == 0)); this.dataContext.SaveChanges(); return this.RedirectToAction("Index"); } this.ViewBag.CompanyId = new SelectList(this.dataContext.Companies, "CompanyId", "CompanyName"); this.ViewBag.SubCategoryId = new SelectList(this.dataContext.Categories, "SubCategoryId", "SubCategoryName"); this.ViewBag.CatagoryId = new HashSet<Category>(this.dataContext.Categories).Select( c => new SelectListItem { Text = c.CategoryName, Value = c.CategoryID.ToString(CultureInfo.InvariantCulture) }); return this.View(product); }