/// <summary> /// 更新付款计划 /// </summary> /// <param name="persistPaymentSchedule"></param> /// <param name="paymentScheduleLines"></param> private void UpdatePaymentSchedule(PaymentSchedule persistPaymentSchedule, List<PaymentScheduleLineDTO> paymentScheduleLines) { var addingPaymentDetail = new List<PaymentScheduleLineDTO>(); //需要添加的付款计划明细 var deletingPaymentDetail = new List<PaymentScheduleLine>(); //需要删除的付款计划明细 paymentScheduleLines.ForEach(p => { //存在付款计划行 PaymentScheduleLine persistPaymentScheduleLine = persistPaymentSchedule.PaymentScheduleLines.FirstOrDefault(c => c.Id == p.PaymentScheduleLineId); //更新 if (persistPaymentScheduleLine != null) { if (!persistPaymentScheduleLine.ScheduleDate.Equals(p.ScheduleDate)) { persistPaymentScheduleLine.SetScheduleDate(p.ScheduleDate); } if (!persistPaymentScheduleLine.Amount.Equals(p.Amount)) { persistPaymentScheduleLine.SetAmount(p.Amount); } if (!persistPaymentScheduleLine.Amount.Equals(p.Amount)) { persistPaymentScheduleLine.SetAmount(p.Amount); } } else { //需要添加的付款计划明细,添加项 addingPaymentDetail.Add(p); } }); persistPaymentSchedule.PaymentScheduleLines.ToList().ForEach(p => { //存在付款计划行 PaymentScheduleLineDTO persistPaymentScheduleLine = paymentScheduleLines.FirstOrDefault(c => c.PaymentScheduleLineId == p.Id); if (persistPaymentScheduleLine == null) { deletingPaymentDetail.Add(p); } }); addingPaymentDetail.ForEach(p => persistPaymentSchedule .AddPaymentScheduleLine(p.ScheduleDate, p.Amount, p.Subject, p.Body, p.Importance, p.ProcessStatus, p.Start, p.End, p.IsAllDayEvent)); deletingPaymentDetail.ForEach(p => _paymentScheduleRepository.RemovePaymentScheduleLine(p)); }
/// <summary> /// 新增付款计划 /// </summary> /// <param name="paymentSchedule"></param> /// <param name="addingPaymentScheduleLines">需要增加的付款计划明细</param> private void InsertPaymentSchedule(PaymentSchedule paymentSchedule, List<PaymentScheduleLineDTO> addingPaymentScheduleLines) { addingPaymentScheduleLines.ForEach(p => paymentSchedule .AddPaymentScheduleLine(p.ScheduleDate, p.Amount, p.Subject, p.Body, p.Importance, p.ProcessStatus, p.Start, p.End, p.IsAllDayEvent)); _paymentScheduleRepository.Add(paymentSchedule); }