private static void AddDocument(DocumentCollection documents, CsvData data)
        {
            DocumentObject document = new DocumentObject(data.DocumentId)
            {
                MatterID = data.MatterId, FileName = data.FileName
            };

            documents.Add(document);
        }
        private static void AddMatter(MatterCollection matters, CsvData data)
        {
            MatterObject matter = new MatterObject(data.MatterId)
            {
                ClientID = data.ClientId
            };

            matters.Add(matter);
        }
        private static void AddClient(ClientCollection clients, CsvData data)
        {
            ClientObject client = new ClientObject(data.ClientId)
            {
                Email = data.Email, PreferredName = data.PreferredName
            };

            clients.Add(client);
        }
        private static MatterObject GetOrAddMatter(ClientObject client, CsvData data)
        {
            MatterObject matter = client.Matters.Where(m => m.MatterID == data.MatterId).FirstOrDefault();

            if (matter == null)
            {
                matter = new MatterObject(data.MatterId);
                client.AddMatter(matter);
            }

            return(matter);
        }
        private static DocumentObject GetOrAddDocument(MatterObject matter, CsvData data)
        {
            DocumentObject document = matter.Documents.Where(d => d.DocumentID == data.DocumentId).FirstOrDefault();

            if (document == null)
            {
                document = new DocumentObject(data.DocumentId)
                {
                    FileName = data.FileName
                };
                matter.AddDocument(document);
            }

            return(document);
        }
        private static ClientObject GetOrAddClient(ClientCollection clients, CsvData data)
        {
            ClientObject client = clients.Where(c => c.ClientID == data.ClientId).FirstOrDefault();

            if (client == null)
            {
                client = new ClientObject(data.ClientId)
                {
                    Email = data.Email, PreferredName = data.PreferredName
                };
                clients.Add(client);
            }

            return(client);
        }
        DataSet IReadParser.UnparseContent(string content)
        {
            ClientCollection clients      = new ClientCollection();
            bool             isHeaderLine = true;

            foreach (string line in content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (isHeaderLine)
                {
                    isHeaderLine = false;
                    continue;
                }
                CsvData      data   = new CsvData(line);
                ClientObject client = GetOrAddClient(clients, data);
                MatterObject matter = GetOrAddMatter(client, data);
                GetOrAddDocument(matter, data);
            }

            return(new DataSet()
            {
                Clients = clients
            });
        }