private void SaveTaxCalculationCompletion(string chosenName, string coinType, decimal exchangeRate, byte nrOfDecimals) { var taxIndicatorModelList = TaxIndicators.ToList().ToCompletedList(); //multiply with the exchange rate taxIndicatorModelList.ForEach(p => { if (!string.IsNullOrEmpty(p.Value)) { var valueDec = DecimalConvertor.Instance.StringToDecimal(p.Value); p.Value = DecimalConvertor.Instance.DecimalToString(valueDec * exchangeRate, nrOfDecimals); } } ); CompletedIndicatorDbModel contentModel = new CompletedIndicatorDbModel() { CompletedIndicators = taxIndicatorModelList, PreviousIndicatorId = null }; if (setupModel.Rectifying) { contentModel.PreviousIndicatorId = setupModel.SelectedTaxCalculation.Id; } var content = VmUtils.SerializeEntity(contentModel); TaxCalculationOtherData otherData = new TaxCalculationOtherData() { VerifiedBy = setupModel.VerifiedBy, CreatedBy = setupModel.CreatedBy, CoinType = coinType, ExchangeRate = exchangeRate, Month = setupModel.Month, NrOfDecimals = setupModel.NrOfDecimals, Name = chosenName + " - " + coinType, Year = setupModel.Year, SecondTypeReport = isSecondTypeReport, LastModifiedDate = DateTime.Now }; //save the data in the DB TaxCalculations tc = new TaxCalculations() { CompanyId = setupModel.SelectedCompany.Id, IndicatorId = setupModel.SelectedIndicatorList.Id, Rectifying = setupModel.Rectifying, Content = content, OtherData = VmUtils.SerializeEntity(otherData) }; taxCalculationRepository.Create(tc); }
private void Save(object parameter) { try { if (TaxIndicators != null) { //perform validation if (IsValid()) { var taxIndicatorModelList = TaxIndicators.ToList().ToCompletedList(); //multiply with the exchange rate //taxIndicatorModelList.ForEach(p => //{ // if (!string.IsNullOrEmpty(p.Value)) // { // var valueDec = DecimalConvertor.Instance.StringToDecimal(p.Value); // p.Value = DecimalConvertor.Instance.DecimalToString(valueDec * initialOtherData.ExchangeRate, initialOtherData.NrOfDecimals); // } //} //); CompletedIndicatorDbModel contentModel = new CompletedIndicatorDbModel() { CompletedIndicators = taxIndicatorModelList, PreviousIndicatorId = null }; var content = VmUtils.SerializeEntity(contentModel); taxCalculationRepository.UpdateContent(selectedTaxCalculationVm.Id, content, ""); WindowHelper.OpenInformationDialog(Messages.InfoWasSaved); //ask the user if he wants version 2, if needed //bool row57Completed = false; //var row57 = GetRowByInnerId(TaxIndicators.ToList(), 57); //if (row57 != null) //{ // row57Completed = DecimalConvertor.Instance.StringToDecimal(row57.ValueField) != 0; //} //if (row57Completed) //{ // //ask the user and wait for the response // Mediator.Instance.Register(MediatorActionType.YesNoPopupResponse, YesNoPopupResponseCallback); // Mediator.Instance.SendMessage(MediatorActionType.OpenWindow, PopupType.YesNoDialog); // Mediator.Instance.SendMessage(MediatorActionType.SetMessage, Messages.GenerateReportType2); //} //else //{ // //save with the selected name // isSecondTypeReport = false; // PerformSave(); //} } else { WindowHelper.OpenErrorDialog(Messages.Error_InvalidFields); } } } catch (Exception ex) { Logger.Instance.LogException(ex); WindowHelper.OpenErrorDialog(Messages.ErrorSavingInfo); } }