public override void LoadModel() { _partysInternal.Clear(); var partys = _modelService.GetCompanies(); foreach (var party in partys) { var partyVM = new CompanyVM(party); partyVM.Payments = _modelService.GetPayments().Where(p => p.PartyId == party.Id).Select(p => new PaymentVM(p)).ToList(); partyVM.Bills = _modelService.GetPurchaseInvoices().Where(b => b.Company.Id == party.Id).Select(b => new InvoiceVM(b, null)).ToList(); //if (partyVM.Bills.Any() || partyVM.Payments.Any()) // _partysInternal.Add(partyVM); } }
public override void LoadModel() { _invoicesInternal.Clear(); var bills = _modelService.GetPurchaseInvoices(); foreach (var bill in bills) { var billVM = new InvoiceVM(bill, this); var party = _modelService.GetCompany(bill.Company.Id); var partyVM = new CompanyVM(party); partyVM.Payments = _modelService.GetPayments().Where(p => p.PartyId == party.Id).Select(p => new PaymentVM(p)).ToList(); partyVM.Bills = _modelService.GetPurchaseInvoices().Where(b => b.Company.Id == party.Id).Select(b => new InvoiceVM(b, this)).ToList(); // billVM.Company = partyVM; if (party != null) { billVM.PartyName = party.Name; } if (billVM.IsPayed) { continue; } if (!billVM.IsDue) { continue; } _invoicesInternal.Add(billVM); } Refresh(); }