public ActionResult CreateProduct(NewProductModel model) { if (!ModelState.IsValid) { return(View("New", model)); } var products = ProductService.GetProducts(); if (products.Any(product => product.Name == model.Name)) { ModelState.AddModelError("Name", "A product with this name was already found."); return(View("New", model)); } try { var product = new Product { Name = model.Name, Description = model.Description, Url = model.Url, CreatedBy = GetCurrentUser().Username }; ProductService.CreateProduct(product); } catch (Exception ex) { QuietLog.LogHandledException(ex); } return(SafeRedirect(Url.AdminProducts())); }