public string ContributionsXML(int startRow, int pageSize) { var xs = new XmlSerializer(typeof(ContributionElements)); var sw = new StringWriter(); PopulateTotals(); var cc = contributions.OrderByDescending(m => m.ContributionDate).Skip(startRow).Take(pageSize); var a = new ContributionElements { NumberOfPages = (int)Math.Ceiling((model.Count ?? 0) / 100.0), NumberOfItems = model.Count ?? 0, TotalAmount = model.Total ?? 0, List = (from c in cc let bd = c.BundleDetails.FirstOrDefault() select new APIContribution.Contribution { ContributionId = c.ContributionId, PeopleId = c.PeopleId ?? 0, Name = c.Person.Name, Date = c.ContributionDate.FormatDate(), Amount = c.ContributionAmount ?? 0, Fund = c.ContributionFund.FundName, Description = c.ContributionDesc, CheckNo = c.CheckNo }).ToArray() }; xs.Serialize(sw, a); return(sw.ToString()); }
public string ContributionsXML(int startRow, int pageSize) { var xs = new XmlSerializer(typeof (ContributionElements)); var sw = new StringWriter(); var cc = FetchContributions(); if (!_count.HasValue) _count = contributions.Count(); cc = cc.OrderByDescending(m => m.ContributionDate).Skip(startRow).Take(pageSize); var a = new ContributionElements { NumberOfPages = (int)Math.Ceiling((_count ?? 0) / 100.0), NumberOfItems = _count ?? 0, TotalAmount = Total(), List = (from c in cc let bd = c.BundleDetails.FirstOrDefault() select new APIContribution.Contribution { ContributionId = c.ContributionId, PeopleId = c.PeopleId ?? 0, Name = c.Person.Name, Date = c.ContributionDate.FormatDate(), Amount = c.ContributionAmount ?? 0, Fund = c.ContributionFund.FundName, Description = c.ContributionDesc, CheckNo = c.CheckNo }).ToArray() }; xs.Serialize(sw, a); return sw.ToString(); }