private PartialViewResult ViewEditPerformanceMeasureExpecteds(Project project, EditPerformanceMeasureExpectedViewModel viewModel) { var performanceMeasures = PerformanceMeasureModelExtensions.GetReportablePerformanceMeasures().ToList(); var viewData = new EditPerformanceMeasureExpectedViewData(project, performanceMeasures); return(RazorPartialView <EditPerformanceMeasureExpected, EditPerformanceMeasureExpectedViewData, EditPerformanceMeasureExpectedViewModel>(viewData, viewModel)); }
private static List <PerformanceMeasureSubcategoriesTotalReportedValue> GetSpendingByPerformanceMeasureByProjectAndGridSpec( out SpendingByPerformanceMeasureByProjectGridSpec gridSpec, PerformanceMeasure performanceMeasure, FirmaSession currentFirmaSession) { gridSpec = new SpendingByPerformanceMeasureByProjectGridSpec(performanceMeasure); return(PerformanceMeasureModelExtensions.SubcategoriesTotalReportedValues(currentFirmaSession, performanceMeasure)); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var errors = new List <ValidationResult>(); var performanceMeasures = HttpRequestStorage.DatabaseEntities.PerformanceMeasures.ToList(); if (!PerformanceMeasureModelExtensions.IsPerformanceMeasureDisplayNameUnique(performanceMeasures, PerformanceMeasureDisplayName, PerformanceMeasureID)) { errors.Add(new SitkaValidationResult <EditViewModel, string>(FirmaValidationMessages.PerformanceMeasureNameUnique, x => x.PerformanceMeasureDisplayName)); } return(errors); }
public void UpdateModel(Models.PerformanceMeasure performanceMeasure) { var performanceMeasureSubcategoriesFromDatabase = HttpRequestStorage.DatabaseEntities.PerformanceMeasureSubcategories.Local; var performanceMeasureSubcategoryOptionsFromDatabase = HttpRequestStorage.DatabaseEntities.PerformanceMeasureSubcategoryOptions.Local; var performanceMeasureSubcategoriesToUpdate = PerformanceMeasureSubcategorySimples.Select(x => { var performanceMeasureSubcategory = new PerformanceMeasureSubcategory(new Models.PerformanceMeasure(String.Empty, default(int), default(int), false, false, true, PerformanceMeasureDataSourceType.Project.PerformanceMeasureDataSourceTypeID), x.PerformanceMeasureSubcategoryDisplayName); performanceMeasureSubcategory.PerformanceMeasure = performanceMeasure; performanceMeasureSubcategory.PerformanceMeasureSubcategoryID = x.PerformanceMeasureSubcategoryID; performanceMeasureSubcategory.PerformanceMeasureSubcategoryOptions = x.PerformanceMeasureSubcategoryOptions.OrderBy(y => y.SortOrder).Select( (y, index) => new PerformanceMeasureSubcategoryOption( new PerformanceMeasureSubcategory(new Models.PerformanceMeasure(String.Empty, default(int), default(int), false, false, true, PerformanceMeasureDataSourceType.Project.PerformanceMeasureDataSourceTypeID), String.Empty), y.PerformanceMeasureSubcategoryOptionName, false) { PerformanceMeasureSubcategory = performanceMeasure.PerformanceMeasureSubcategories.SingleOrDefault(z => z.PerformanceMeasureSubcategoryID == x.PerformanceMeasureSubcategoryID), PerformanceMeasureSubcategoryOptionID = y.PerformanceMeasureSubcategoryOptionID, SortOrder = index + 1, ShowOnFactSheet = y.ShowOnFactSheet }).ToList(); var chartConfigurationJson = JObject.FromObject(PerformanceMeasureModelExtensions.GetDefaultPerformanceMeasureChartConfigurationJson(performanceMeasure)).ToString(); performanceMeasureSubcategory.ChartConfigurationJson = chartConfigurationJson; performanceMeasureSubcategory.GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID; return(performanceMeasureSubcategory); }).ToList(); var performanceMeasureSubcategoryOptionsToUpdate = performanceMeasureSubcategoriesToUpdate.SelectMany(x => x.PerformanceMeasureSubcategoryOptions).ToList(); performanceMeasure.PerformanceMeasureSubcategories.SelectMany(x => x.PerformanceMeasureSubcategoryOptions).ToList().Merge( performanceMeasureSubcategoryOptionsToUpdate, performanceMeasureSubcategoryOptionsFromDatabase, (x, y) => x.PerformanceMeasureSubcategoryOptionID == y.PerformanceMeasureSubcategoryOptionID, (x, y) => { x.PerformanceMeasureSubcategoryOptionName = y.PerformanceMeasureSubcategoryOptionName; x.SortOrder = y.SortOrder; x.ShowOnFactSheet = y.ShowOnFactSheet; }); performanceMeasure.PerformanceMeasureSubcategories.Merge(performanceMeasureSubcategoriesToUpdate, performanceMeasureSubcategoriesFromDatabase, (x, y) => x.PerformanceMeasureSubcategoryID == y.PerformanceMeasureSubcategoryID, (x, y) => { x.PerformanceMeasureSubcategoryDisplayName = y.PerformanceMeasureSubcategoryDisplayName; }); }
private PartialViewResult ViewEditPerformanceMeasureExpecteds(Project project, EditPerformanceMeasureExpectedViewModel viewModel) { var performanceMeasures = PerformanceMeasureModelExtensions.GetReportablePerformanceMeasures().ToList(); var configurePerformanceMeasuresUrl = string.Empty; if (new PerformanceMeasureManageFeature().HasPermissionByFirmaSession(CurrentFirmaSession)) { configurePerformanceMeasuresUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.Manage()); } var viewData = new EditPerformanceMeasureExpectedViewData(project, performanceMeasures, configurePerformanceMeasuresUrl); return(RazorPartialView <EditPerformanceMeasureExpected, EditPerformanceMeasureExpectedViewData, EditPerformanceMeasureExpectedViewModel>(viewData, viewModel)); }
private PartialViewResult ViewEditPerformanceMeasureActuals(Project project, EditPerformanceMeasureActualsViewModel viewModel) { var performanceMeasures = PerformanceMeasureModelExtensions.GetReportablePerformanceMeasures().ToList().SortByOrderThenName().ToList(); var showExemptYears = project.GetPerformanceMeasuresExemptReportingYears().Any() || ModelState.Values.SelectMany(x => x.Errors) .Any( x => x.ErrorMessage == FirmaValidationMessages.ExplanationNotNecessaryForProjectExemptYears || x.ErrorMessage == FirmaValidationMessages.ExplanationNecessaryForProjectExemptYears); var viewData = new EditPerformanceMeasureActualsViewData(project, performanceMeasures, showExemptYears); return(RazorPartialView <EditPerformanceMeasureActuals, EditPerformanceMeasureActualsViewData, EditPerformanceMeasureActualsViewModel>(viewData, viewModel)); }
public ActionResult ResetChartConfiguration(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey, PerformanceMeasureSubcategoryPrimaryKey performanceMeasureSubcategoryPrimaryKey, ConfirmDialogFormViewModel viewModel) { var performanceMeasure = performanceMeasurePrimaryKey.EntityObject; var performanceMeasureSubcategoryID = performanceMeasureSubcategoryPrimaryKey.EntityObject.PerformanceMeasureSubcategoryID; if (!ModelState.IsValid) { SetErrorForDisplay("Error resetting chart configuration."); return(ViewResetChartConfiguration(performanceMeasure, viewModel)); } var performanceMeasureSubcategory = performanceMeasure.PerformanceMeasureSubcategories.Single(x => x.PerformanceMeasureSubcategoryID == performanceMeasureSubcategoryID); var defaultSubcategoryChartConfigurationJson = PerformanceMeasureModelExtensions.GetDefaultPerformanceMeasureChartConfigurationJson(performanceMeasure); performanceMeasureSubcategory.ChartConfigurationJson = JObject.FromObject(defaultSubcategoryChartConfigurationJson).ToString(); performanceMeasureSubcategory.GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID; return(new ModalDialogFormJsonResult()); }
public ActionResult New(EditViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEdit(viewModel)); } var performanceMeasure = new PerformanceMeasure(default(string), default(int), default(int), false, false, true, PerformanceMeasureDataSourceType.Project.PerformanceMeasureDataSourceTypeID); viewModel.UpdateModel(performanceMeasure, CurrentPerson); var defaultSubcategory = new PerformanceMeasureSubcategory(performanceMeasure, "Default") { GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID }; var defaultSubcategoryChartConfigurationJson = PerformanceMeasureModelExtensions.GetDefaultPerformanceMeasureChartConfigurationJson(performanceMeasure); defaultSubcategory.ChartConfigurationJson = JObject.FromObject(defaultSubcategoryChartConfigurationJson).ToString(); new PerformanceMeasureSubcategoryOption(defaultSubcategory, "Default", false); HttpRequestStorage.DatabaseEntities.PerformanceMeasures.Add(performanceMeasure); HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"New {MultiTenantHelpers.GetPerformanceMeasureName()} '{performanceMeasure.GetDisplayNameAsUrl()}' successfully created!"); return(new ModalDialogFormJsonResult()); }