public ActionResult CreatePost(CreateProductTypeViewModel viewModel) { if (!_orchardServices.Authorizer.Authorize(Permissions.ManageProductTypes)) { return new HttpUnauthorizedResult(); } viewModel.DisplayName = viewModel.DisplayName ?? string.Empty; if (string.IsNullOrEmpty(viewModel.DisplayName)) { _orchardServices.TransactionManager.Cancel(); ModelState.AddModelError("DisplayName", T("Name is mandatory").Text); return View(viewModel); } var result = _productService.CreateProductType(viewModel.DisplayName); if (!result) { _orchardServices.TransactionManager.Cancel(); _orchardServices.Notifier.Error(T("Could not create {0}, the type already exists", viewModel.DisplayName)); return View(viewModel); } var name = viewModel.DisplayName.ToSafeName(); _orchardServices.Notifier.Information(T("Product type {0} successfully created", viewModel.DisplayName)); return RedirectToAction("AddPartsTo", "Admin", new { Area = "Orchard.ContentTypes", id = name }); }
public ActionResult Create() { if (!_orchardServices.Authorizer.Authorize(Permissions.ManageProductTypes)) { return new HttpUnauthorizedResult(); } var viewModel = new CreateProductTypeViewModel(); return View(viewModel); }