public CategoryViewModel Category(CategoryInputModel inputModel) { CategoryViewModel viewModel = new CategoryViewModel(); //initialize the dropdownlist values string ex; var performanceCounterCategories = _performanceMonitorService.CategoryNames(out ex).ToList(); if (ex == string.Empty) { var categoryList = performanceCounterCategories.Select(c => new SelectListItem { Text = c.ToString(), Value = c.ToString() }); viewModel.Accessible = true; viewModel.CategoryList = new SelectList(categoryList, "Value", "Text", inputModel.CategoryName); return viewModel; } else { _notifier.Error(T("Error: Not able to load the categories. Exception: {0} ", ex)); viewModel.Accessible = false; return viewModel; } }
//[HandleError, OrchardAuthorization(PermissionName = OrchardPermissionStrings.SiteOwner)] public ActionResult Category(CategoryInputModel inputModel) { CategoryViewModel viewModel = _performanceMonitorWorkerService.Category(inputModel); if (viewModel.Accessible == false) { return RedirectToAction("Index"); } return View(viewModel); }
//[HandleError, OrchardAuthorization(PermissionName = ApplicationFrameworkPermissionStrings.EditConfigurationSettings)] public ActionResult CategoryPost(CategoryPostInputModel inputModel) { if (!ModelState.IsValid) { CategoryInputModel catInputModel = new CategoryInputModel(); CategoryViewModel viewModel = _performanceMonitorWorkerService.Category(catInputModel); return View("Category", viewModel); } string categoryName = inputModel.CategoryName; bool multiInstanceType = _performanceMonitorWorkerService.CheckForMultiInstanceType(categoryName); if (multiInstanceType) { return RedirectToAction("CategoryInstance", "PerformanceMonitor", new { selectedCategoryName = categoryName }); } return RedirectToAction("Edit", "PerformanceMonitor", new { selectedCategoryName = categoryName, selectedInstanceName = "none" }); }