using System; using System.Collections.Generic; using System.Linq; using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Service.DCEntityMapper; using BS.Shared.Core; using BS.Shared.DataContracts.Compact; namespace BeWo.Report.ReportObjects { public class PersonListRO : AbstractBeWoReportObject { public List PrintObjectList { get; set; } public static PersonListRO Create(List oids) { var ro = new PersonListRO(); ro.PrintObjectList = new List(); var persons = DAOFactory.GenericDAO.LoadByIDs(oids); var compactPersons = MapperFactory.CompactPersonDC_Person.MapToNewDCs(persons); //Kontaktinfos setzen, weil sonst null foreach (var p in compactPersons) { var entity = persons.First(e => e.Oid == p.PersonOid); if (entity.Contacts != null && entity.Contacts.Count > 0) { var telefon = entity.Contacts.FirstOrDefault(c => c.Type == BS.Shared.ContactType.private_Phone); var mobil = entity.Contacts.FirstOrDefault(c => c.Type == BS.Shared.ContactType.private_MobilePhone); var mail = entity.Contacts.FirstOrDefault(c => c.Type == BS.Shared.ContactType.private_Mail); var fax = entity.Contacts.FirstOrDefault(c => c.Type == BS.Shared.ContactType.private_Fax); p.Communication1 = telefon != null ? telefon.Value : ""; // telefon p.Communication2 = mobil != null ? mobil.Value : ""; // mobil p.Communication3 = mail != null ? mail.Value : ""; // mail p.Communication4 = fax != null ? fax.Value : ""; // fax } ro.PrintObjectList.Add(new PrintObject() { CompactPerson = p, Bemerkung = entity.Notice }); } return ro; } } public class PrintObject { public CompactPersonDC CompactPerson { get; set; } public string Bemerkung { get; set; } } }