using System; using System.Collections.Generic; using System.Linq; using BeWo.Data.Access; using BeWo.Data.Entities; using BS.Shared; using BS.Shared.DataContracts; namespace BeWo.Report.ReportObjects { public class NotizenRO : AbstractBeWoReportObject { public List Eintraege { get; set; } public DateTime Start { get; set; } public DateTime End { get; set; } public String FirstName { get; set; } public String LastName { get; set; } public static NotizenRO Create(DateTime start, DateTime end, NotizenKategorieDC notizenKategorie) { var ro = new NotizenRO(); ro.Start = start; ro.End = end; Person p = null; if (notizenKategorie.ObjectTid == TableID.Customer) { p = DAOFactory.GenericDAO.LoadByID(notizenKategorie.ObjectOid.Value).Person; } else if (notizenKategorie.ObjectTid == TableID.Employee) { p = DAOFactory.GenericDAO.LoadByID(notizenKategorie.ObjectOid.Value).Person; } if (p != null) { ro.FirstName = p.FirstName; ro.LastName = p.LastName; } ro.Eintraege = notizenKategorie.NotizenEintraege .Where(w => w.Datum != null && w.Datum.Value >= start && w.Datum.Value <= end) .OrderBy(o => o.Datum).ToList(); return ro; } } }