public void Modify(object parameter) { //Mediator.Instance.SendMessage(MediatorActionType.SetMainContent, ContentTypes.ExistingTaxCalculationCompletion); //Mediator.Instance.SendMessage(MediatorActionType.SetSetupModel, parameter); var paramCalculation = parameter as TaxCalculationsViewModel; var selectedCalculation = taxCalculationRepository.Get(paramCalculation.Id); TaxCalculationOtherData otherData = VmUtils.Deserialize<TaxCalculationOtherData>(selectedCalculation.OtherData); TaxCalculationSetupModel setupModel = new TaxCalculationSetupModel() { CoinType = otherData.CoinType, ExchangeRate = otherData.ExchangeRate, Month = otherData.Month, NrOfDecimals = (byte)otherData.NrOfDecimals, //Rectifying = selectedCalculation.Rectifying, //always treat this as rectifying=false when editing it Rectifying = false, SelectedCompany = selectedCalculation.Company, SelectedIndicatorList = selectedCalculation.Indicator, VerifiedBy = otherData.VerifiedBy, CreatedBy = otherData.CreatedBy, Year = otherData.Year, SelectedTaxCalculation = new TaxCalculationSelection() { Id = selectedCalculation.Id }, CompletedTaxIndicatorId = selectedCalculation.Id, BackToReports = true }; Mediator.Instance.SendMessage(MediatorActionType.SetMainContent, ContentTypes.TaxCalculationCompletion); Mediator.Instance.SendMessage(MediatorActionType.SetSetupModel, setupModel); }
private void AddValues(object parameter) { if (!IsValid()) { WindowHelper.OpenErrorDialog(Messages.Error_MissingFields); return; } //verify if the company/indicatorl list /month/year combination already exist //get all the calculations for this company and indicator list if (!Rectifying) { var validIndicatorList = GetValidIndicatorList(); //var existingCalculations = taxCalculationsRepository.GetAll().Where(p => p.CompanyId == SelectedCompany.Id && p.IndicatorId == SelectedIndicatorList.Id && !p.Rectifying).ToList(); var existingCalculations = taxCalculationsRepository.GetAll().Where(p => p.CompanyId == SelectedCompany.Id && validIndicatorList.Contains(p.IndicatorId) && !p.Rectifying).ToList(); if (existingCalculations != null && existingCalculations.Count > 0) { foreach (var item in existingCalculations) { TaxCalculationOtherData otherData = VmUtils.Deserialize<TaxCalculationOtherData>(item.OtherData); if (otherData.Month == SelectedMonth && otherData.Year == SelectedYear) { WindowHelper.OpenErrorDialog(Messages.Error_ExistingCalculationForSetup); return; } } } } //save the last filled in values SaveLastSetupValues(); //save all the last values SaveLastSetupValuesEntireScreen(); Indicator oldIndicator = null; if (SelectedTaxCalculation != null) { oldIndicator = indicatorRepository.Get(SelectedTaxCalculation.InitialIndicatorId); } else { oldIndicator = SelectedIndicatorList; } //load the selected data and navigate to the fill-in screen TaxCalculationSetupModel setupModel = new TaxCalculationSetupModel() { //CS: removed coin type and exchange rate CoinType = "LEI", ExchangeRate = 0, Month = SelectedMonth, NrOfDecimals = SelectedNrOfDecimals, Rectifying = Rectifying, SelectedCompany = SelectedCompany, //SelectedIndicatorList = SelectedIndicatorList, SelectedIndicatorList = oldIndicator, VerifiedBy = VerifiedBy, CreatedBy = CreatedBy, Year = SelectedYear, SelectedTaxCalculation = SelectedTaxCalculation }; Mediator.Instance.SendMessage(MediatorActionType.SetMainContent, ContentTypes.TaxCalculationCompletion); Mediator.Instance.SendMessage(MediatorActionType.SetSetupModel, setupModel); }