public ActionResult ResetChartConfiguration(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey,
                                                    int performanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration chartConfiguration,
                                                    ConfirmDialogFormViewModel viewModel)
        {
            var performanceMeasure = performanceMeasurePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                SetErrorForDisplay("Error resetting chart configuration.");
                return(ViewResetChartConfiguration(performanceMeasure, viewModel));
            }

            var performanceMeasureSubcategory = performanceMeasure.PerformanceMeasureSubcategories.Single(x =>
                                                                                                          x.PerformanceMeasureSubcategoryID == performanceMeasureSubcategoryID);
            GoogleChartConfiguration defaultSubcategoryChartConfigurationJson =
                performanceMeasure.GetDefaultPerformanceMeasureChartConfigurationJson();

            switch (chartConfiguration)
            {
            case PerformanceMeasureSubcategoryChartConfiguration.ChartConfiguration:
                performanceMeasureSubcategory.ChartConfigurationJson =
                    JObject.FromObject(defaultSubcategoryChartConfigurationJson).ToString();
                performanceMeasureSubcategory.GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID;
                break;

            case PerformanceMeasureSubcategoryChartConfiguration.CumulativeConfiguration:
                performanceMeasureSubcategory.CumulativeChartConfigurationJson =
                    JObject.FromObject(defaultSubcategoryChartConfigurationJson).ToString();
                performanceMeasureSubcategory.CumulativeGoogleChartTypeID =
                    GoogleChartType.ColumnChart.GoogleChartTypeID;
                break;

            default:
                throw new ArgumentOutOfRangeException(
                          $"Invalid PerformanceMeasureSubcategoryChartConfiguration: '{chartConfiguration}'");
            }

            return(new ModalDialogFormJsonResult());
        }
        public PartialViewResult ResetChartConfiguration(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey,
                                                         int performanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration chartConfiguration)
        {
            var performanceMeasure = performanceMeasurePrimaryKey.EntityObject;
            var viewModel          = new ConfirmDialogFormViewModel(performanceMeasure.PerformanceMeasureID);

            return(ViewResetChartConfiguration(performanceMeasure, viewModel));
        }
 public ContentResult SaveChartConfiguration(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey,
                                             int performanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration chartConfiguration)
 {
     return(new ContentResult());
 }
        public ActionResult SaveChartConfiguration(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey,
                                                   int performanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration chartConfiguration,
                                                   GoogleChartConfigurationViewModel viewModel)
        {
            var performanceMeasure = performanceMeasurePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                SetErrorForDisplay("Unable to save chart configuration: Unsupported options.");
            }
            else
            {
                viewModel.UpdateModel(performanceMeasure, performanceMeasureSubcategoryID, chartConfiguration);
            }

            return(RedirectToAction(new SitkaRoute <PerformanceMeasureController>(x => x.Detail(performanceMeasure))));
        }
Esempio n. 5
0
        public void UpdateModel(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, int performanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration chartConfiguration)
        {
            //Remove certain properties that we don't want saved to the DB
            var chartConfigurationString      = CleanAndSerializeChartJsonString(ChartConfigurationJson);
            var performanceMeasureSubcategory = performanceMeasure.PerformanceMeasureSubcategories.Single(x => x.PerformanceMeasureSubcategoryID == performanceMeasureSubcategoryID);
            var googleChartType = ConvertChartTypeStringToGoogleChartType();

            switch (chartConfiguration)
            {
            case PerformanceMeasureSubcategoryChartConfiguration.ChartConfiguration:
                performanceMeasureSubcategory.GoogleChartTypeID      = googleChartType != null ? googleChartType.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                performanceMeasureSubcategory.ChartConfigurationJson = chartConfigurationString;
                break;

            case PerformanceMeasureSubcategoryChartConfiguration.CumulativeConfiguration:
                performanceMeasureSubcategory.CumulativeGoogleChartTypeID      = googleChartType != null ? googleChartType.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                performanceMeasureSubcategory.CumulativeChartConfigurationJson = chartConfigurationString;
                break;

            default:
                throw new ArgumentOutOfRangeException($"Invalid PerformanceMeasureSubcategoryChartConfiguration: '{chartConfiguration}'");
            }
        }