public ActionResult Update(UpdateKpiViewModel viewModel) { viewModel.YtdFormula = (DSLNG.PEAR.Web.ViewModels.Kpi.YtdFormula)Enum.Parse(typeof(DSLNG.PEAR.Data.Enums.YtdFormula), viewModel.YtdFormulaValue); viewModel.Periode = (DSLNG.PEAR.Web.ViewModels.Kpi.PeriodeType)Enum.Parse(typeof(DSLNG.PEAR.Data.Enums.PeriodeType), viewModel.PeriodeValue); viewModel.Code = string.Format("{0}{1}{2}{3}", viewModel.CodeFromPillar, viewModel.CodeFromLevel, viewModel.Code, viewModel.CodeFromRoleGroup); var request = viewModel.MapTo <UpdateKpiRequest>(); var response = _kpiService.Update(request); TempData["IsSuccess"] = response.IsSuccess; TempData["Message"] = response.Message; if (response.IsSuccess) { return(RedirectToAction("Index")); } 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 (viewModel.RelationModels.Count == 0) { viewModel.RelationModels.Add(new ViewModels.Kpi.KpiRelationModel { KpiId = 0, Method = "" }); } return(View("Update", viewModel)); }
public ActionResult Update(UpdateKpiViewModel viewModel) { viewModel.YtdFormula = (ViewModels.Kpi.YtdFormula)Enum.Parse(typeof(Data.Enums.YtdFormula), viewModel.YtdFormulaValue); viewModel.Periode = (ViewModels.Kpi.PeriodeType)Enum.Parse(typeof(Data.Enums.PeriodeType), viewModel.PeriodeValue); viewModel.Code = string.Format("{0}{1}{2}{3}", viewModel.CodeFromPillar, viewModel.CodeFromLevel, viewModel.Code, viewModel.CodeFromRoleGroup); //if(viewModel.YtdFormula != ViewModels.Kpi.YtdFormula.Custom) //{ // viewModel.CustomFormula = null; //} if (viewModel.MethodId == 3) { viewModel.CustomFormula = null; } var request = viewModel.MapTo <UpdateKpiRequest>(); request.ActionName = "Update"; request.ControllerName = "KPI"; request.UserId = this.UserProfile().UserId; if (!ModelState.IsValid) { return(View("Update", viewModel)); } var response = _kpiService.Update(request); TempData["IsSuccess"] = response.IsSuccess; TempData["Message"] = response.Message; if (response.IsSuccess) { return(RedirectToAction("Index")); } 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 (viewModel.RelationModels.Count == 0) { viewModel.RelationModels.Add(new ViewModels.Kpi.KpiRelationModel { KpiId = 0, Method = "" }); } return(View("Update", viewModel)); }