private InvestmentInfo GetInvestmentInfo() { var investmentInfo = new InvestmentInfo(); for (var i = 0; i < _table1Column3Editors.Count; i++) { var termValue = _table1Column3Editors[i].EditValue as ListDataItem ?? new ListDataItem { Value = _table1Column3Editors[i].EditValue as String }; if (String.Equals(termValue?.Value, ContractTabBInfo.TermMonthlyInvestment, StringComparison.OrdinalIgnoreCase)) { investmentInfo.MonthlyInvestment += ((decimal?)_table1Column2Editors[i].EditValue ?? 0m); } else if (String.Equals(termValue?.Value, ContractTabBInfo.TermOneTimeInvestment, StringComparison.OrdinalIgnoreCase)) { var investmentValue = ((decimal?)_table1Column2Editors[i].EditValue ?? 0m); var descriptionValue = (_table1Column1Editors[i].EditValue as ListDataItem ?? new ListDataItem { Value = _table1Column1Editors[i].EditValue as String }).Value; investmentInfo.OneTimeInvestmentsList.Add(new Tuple <String, Decimal>(descriptionValue, investmentValue)); } } for (var i = 0; i < _table2Column3Editors.Count; i++) { var termValue = _table2Column3Editors[i].EditValue as ListDataItem ?? new ListDataItem { Value = _table2Column3Editors[i].EditValue as String }; if (String.Equals(termValue?.Value, ContractTabBInfo.TermMonthlyInvestment, StringComparison.OrdinalIgnoreCase)) { investmentInfo.MonthlyInvestment += ((decimal?)_table2Column2Editors[i].EditValue ?? 0m); } else if (String.Equals(termValue?.Value, ContractTabBInfo.TermOneTimeInvestment, StringComparison.OrdinalIgnoreCase)) { var investmentValue = ((decimal?)_table2Column2Editors[i].EditValue ?? 0m); var descriptionValue = (_table2Column1Editors[i].EditValue as ListDataItem ?? new ListDataItem { Value = _table2Column1Editors[i].EditValue as String }).Value; investmentInfo.OneTimeInvestmentsList.Add(new Tuple <String, Decimal>(descriptionValue, investmentValue)); } } try { investmentInfo.MonthCount = Int32.Parse((comboBoxEditSummary2Combo.EditValue as ListDataItem ?? new ListDataItem { Value = comboBoxEditSummary2Combo.EditValue as String }).Value ?? "0"); } catch { } return(investmentInfo); }
public override async Task <Result> Handle(EditInvestmentInfoCommand request, CancellationToken cancellationToken) { var id = string.IsNullOrWhiteSpace(request.Id) ? 0 : Convert.ToInt32(request.Id); var show = request.Show == "1"; var sort = Convert.ToInt32(request.Sort); var typeId = Convert.ToInt32(request.InvestmentTypeId); if (!await _InvestmentTypeRepository.AnyAsync(x => x.Id == typeId)) { return(Result.Failure($"typeId={typeId}类型不存在")); } if (id <= 0) //新增 { var item = new InvestmentInfo() { Content = request.Content, Show = true, Sort = 0, InvestmentTypeId = typeId, Title = request.Title, Status = 0, UserId = request.LoginUser.Id, Describe = request.Content.FilterHtml().Cut(300) }; if (request.LoginUser.Type == 1) { item.Status = 1; } await _InvestmentInfoRepository.AddAsync(item); } else { //修改 var item = await _InvestmentInfoRepository.Set().FirstOrDefaultAsync(x => x.Id == id); if (item == null) { return(Result.Failure($"id={request.Id}错误,内容不存在")); } if (!request.LoginUser.IsAdmin && item.Status == 1) { return(Result.Failure($"当前状态不能修改!")); } item.Content = request.Content; item.Title = request.Title; item.InvestmentTypeId = typeId; item.Status = 0; item.Describe = request.Content.FilterHtml().Cut(300); if (request.LoginUser.Type == 1) //管理员修改 { if (string.IsNullOrWhiteSpace(request.Status)) { return(Result.Failure($"请选择审核状态")); } var status = Convert.ToInt32(request.Status); item.Show = show; item.Sort = sort; item.Status = status; } await _InvestmentInfoRepository.UpdateAsync(item); } return(Result.Success()); }