public ActionResult Edit(CatalogViewModel catalogviewmodel) { if (ModelState.IsValid) { var old = catalogManager.GetCatalog(catalogviewmodel.Code); if (old == null) { return(HttpNotFound()); } old.Code = catalogviewmodel.Code; old.Description = catalogviewmodel.Description; old.Products.Clear(); old.Products = productManager.GetProducts(x => catalogviewmodel.SelectedProducts.Contains(x.Code)); catalogManager.UpdateCatalog(old); return(RedirectToAction("Index")); } return(View(catalogviewmodel)); }