public ActionResult Create(ProductBundleEditAdminViewModel viewModel, string createAndView) { StoreFront storeFront = CurrentStoreFrontOrThrow; bool urlIsValid = GStoreDb.ValidateProductBundleUrlName(this, viewModel.UrlName, storeFront.StoreFrontId, storeFront.ClientId, null); if (urlIsValid && ModelState.IsValid) { try { ProcessFileUploads(viewModel, storeFront); ProductBundle productBundle = GStoreDb.CreateProductBundle(viewModel, storeFront, CurrentUserProfileOrThrow); AddUserMessage("Product Bundle Created!", "Product Bundle '" + productBundle.Name.ToHtml() + "' [" + productBundle.ProductBundleId + "] was created successfully for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Success); if (!string.IsNullOrWhiteSpace(createAndView)) { return RedirectToAction("Details", new { id = productBundle.ProductBundleId, returnToFrontEnd = viewModel.ReturnToFrontEnd, tab = viewModel.ActiveTab }); } if (viewModel.ReturnToFrontEnd) { return RedirectToAction("ViewBundleByName", "Catalog", new { area = "", urlName = viewModel.UrlName } ); } if (storeFront.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.Bundles_Manager)) { return RedirectToAction("Manager", new { ProductCategoryId = productBundle.ProductCategoryId }); } return RedirectToAction("Index", "CatalogAdmin"); } catch (Exception ex) { string errorMessage = "An error occurred while Creating Product Bundle '" + viewModel.Name + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "] \nError: " + ex.GetType().FullName; if (CurrentUserProfileOrThrow.AspNetIdentityUserIsInRoleSystemAdmin()) { errorMessage += " \nException.ToString(): " + ex.ToString(); } AddUserMessage("Error Creating Product Bundle!", errorMessage.ToHtmlLines(), UserMessageType.Danger); ModelState.AddModelError("Ajax", errorMessage); } } else { AddUserMessage("Create Product Bundle Error", "There was an error with your entry for new Product Bundle '" + viewModel.Name.ToHtml() + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]. Please correct it below and save.", UserMessageType.Danger); } if (Request.HasFiles()) { AddUserMessage("Files not uploaded", "You must correct the form values below and re-upload your files", UserMessageType.Danger); } viewModel.FillListsIfEmpty(storeFront.Client, storeFront); viewModel.IsCreatePage = true; ViewData.Add("ReturnToFrontEnd", viewModel.ReturnToFrontEnd); return View("CreateOrEdit", viewModel); }