public CategoryInstanceViewModel CategoryInstance(CategoryInstanceInputModel inputModel) { //initialize the dropdownlist values string myCatName = inputModel.CategoryName; var performanceCounterInstanceNames = _performanceMonitorService.GetInstanceNames(myCatName); var instanceList = performanceCounterInstanceNames.Select(c => new SelectListItem { Text = c.ToString(), Value = c.ToString() }); bool accessibleValue = true; if (performanceCounterInstanceNames.Count == 0) { _notifier.Error(T("Error: Category and instances not accessible")); accessibleValue = false; } CategoryInstanceViewModel viewModel = new CategoryInstanceViewModel() { InstanceList = new SelectList(instanceList, "Value", "Text", inputModel.InstanceName), Accessible = accessibleValue }; return viewModel; }
//[HandleError, OrchardAuthorization(PermissionName = OrchardPermissionStrings.SiteOwner)] public ActionResult CategoryInstance(string selectedCategoryName) { CategoryInstanceInputModel inputModel = new CategoryInstanceInputModel(); inputModel.CategoryName = selectedCategoryName; CategoryInstanceViewModel viewModel = _performanceMonitorWorkerService.CategoryInstance(inputModel); viewModel.CategoryName = selectedCategoryName; if (viewModel.Accessible == false) { return RedirectToAction("Category"); } return View(viewModel); }
//[HandleError, OrchardAuthorization(PermissionName = ApplicationFrameworkPermissionStrings.EditConfigurationSettings)] public ActionResult CategoryInstancePost(CategoryInstancePostInputModel inputModel) { if (!ModelState.IsValid) { CategoryInstanceInputModel catInstanceInputModel = new CategoryInstanceInputModel(); catInstanceInputModel.CategoryName = inputModel.CategoryName; CategoryInstanceViewModel viewModel = _performanceMonitorWorkerService.CategoryInstance(catInstanceInputModel); return View("CategoryInstance", viewModel); } string categoryName = inputModel.CategoryName; string instanceName = inputModel.InstanceName; return RedirectToAction("Edit", "PerformanceMonitor", new { selectedCategoryName = categoryName, selectedInstanceName = instanceName }); }