public ActionResult Edit(int id) { var viewModel = _operationConfigService.GetOperation(new GetOperationRequest { Id = id }).MapTo <OperationViewModel>(); viewModel.KeyOperationGroups = _operationConfigService.GetOperationGroups().OperationGroups .Select( x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList(); viewModel.Kpis = new List <OperationViewModel.Kpi>(); var kpi = _kpiService.GetKpi(new GetKpiRequest { Id = viewModel.KpiId }); viewModel.Kpis.Insert(0, new OperationViewModel.Kpi { Id = kpi.Id, Name = kpi.Name }); return(View(viewModel)); }
public ActionResult Update(int id) { var response = _kpiService.GetKpi(new GetKpiRequest { Id = id }); var viewModel = response.MapTo <UpdateKpiViewModel>(); viewModel.LevelList = _dropdownService.GetLevels().MapTo <SelectListItem>(); viewModel.PillarList = _dropdownService.GetPillars().MapTo <SelectListItem>(); viewModel.RoleGroupList = _dropdownService.GetRoleGroups().MapTo <SelectListItem>(); viewModel.TypeList = _dropdownService.GetTypes().MapTo <SelectListItem>(); viewModel.GroupList = _dropdownService.GetGroups().MapTo <SelectListItem>(); viewModel.YtdFormulaList = _dropdownService.GetYtdFormulas().MapTo <SelectListItem>(); viewModel.PeriodeList = _dropdownService.GetPeriodeTypes().MapTo <SelectListItem>(); viewModel.MethodList = _dropdownService.GetMethods().MapTo <SelectListItem>(); viewModel.MeasurementList = _dropdownService.GetMeasurement().MapTo <SelectListItem>(); viewModel.KpiList = _dropdownService.GetKpis().MapTo <SelectListItem>(); viewModel.YtdFormulaList = _dropdownService.GetYtdFormulas().MapTo <SelectListItem>(); viewModel.PeriodeList = _dropdownService.GetPeriodeTypes().MapTo <SelectListItem>(); if (!string.IsNullOrEmpty(viewModel.Code)) { var numbers = String.Join("", viewModel.Code.Where(char.IsDigit)); //var code = 3; //var takeCode = viewModel.Code.Length - 3; if (viewModel.PillarId.HasValue) { viewModel.CodeFromPillar = GetPillarCode(viewModel.PillarId.Value); //code += 2; //takeCode -= viewModel.CodeFromPillar.Length; } viewModel.CodeFromLevel = GetLevelCode(viewModel.LevelId); if (viewModel.RoleGroupId.HasValue) { viewModel.CodeFromRoleGroup = !string.IsNullOrEmpty(GetRoleGroupCode(viewModel.RoleGroupId.Value)) ? GetRoleGroupCode(viewModel.RoleGroupId.Value) : ""; //takeCode -= viewModel.CodeFromRoleGroup.Length; } //viewModel.Code = response.Code.Substring(code, takeCode); viewModel.Code = numbers; } if (viewModel.RelationModels.Count == 0) { viewModel.RelationModels.Add(new ViewModels.Kpi.KpiRelationModel { KpiId = 0, Method = "" }); } viewModel.Icon = response.Icon; viewModel.Icons = Directory.EnumerateFiles(Server.MapPath(PathConstant.KpiPath)).ToList(); return(View(viewModel)); }
public ActionResult ChartYtd(ViewModels.PmsSummary.ChartViewModel viewModel) { var kpi = _kpiService.GetKpi(new GetKpiRequest { Id = viewModel.Id }); if (kpi.YtdFormula == YtdFormula.Sum) { var artifactDesignerViewModel = new ArtifactDesignerViewModel(); artifactDesignerViewModel.BarChart = new BarChartViewModel(); var previewViewModel = new ArtifactPreviewViewModel(); artifactDesignerViewModel.BarChart.Series.Add(new BarChartViewModel.SeriesViewModel { KpiId = viewModel.Id, Label = "Achievement", ValueAxis = ValueAxis.KpiActual.ToString() }); var request = new GetCartesianChartDataRequest(); request.GraphicName = "Year To Date"; request.GraphicType = "barachievement"; request.HeaderTitle = "Year To Date"; request.MeasurementId = viewModel.MeasurementId; request.PeriodeType = PeriodeType.Monthly; request.RangeFilter = RangeFilter.YTD; request.Start = new DateTime(viewModel.Year, 1, 1); request.End = new DateTime(viewModel.Year, 12, 1); request.ValueAxis = ValueAxis.KpiActual; artifactDesignerViewModel.BarChart.MapPropertiesToInstance <GetCartesianChartDataRequest>(request); var chartData = _artifactService.GetChartData(request); previewViewModel.GraphicType = "barachievement"; previewViewModel.BarChart = new BarChartDataViewModel(); previewViewModel.BarChart.Title = "Year To Date"; previewViewModel.BarChart.ValueAxisTitle = _measurementService.GetMeasurement(new GetMeasurementRequest { Id = viewModel.MeasurementId }).Name; previewViewModel.BarChart.Series = chartData.Series.MapTo <BarChartDataViewModel.SeriesViewModel>(); previewViewModel.BarChart.Periodes = chartData.Periodes; previewViewModel.BarChart.SeriesType = chartData.SeriesType; previewViewModel.PeriodeType = "Monthly"; previewViewModel.TimePeriodes = chartData.TimePeriodes; return(Json(previewViewModel, JsonRequestBehavior.AllowGet)); } return(Content("KPI's Year To Date formula is not SUM type")); }