private Tuple <List <ReceivedLetter>, List <SendLetter> > GetChildItem(Guid parentId, Tuple <List <ReceivedLetter>, List <SendLetter> > emptylists) { var gettedRow = GetRowsByParent(parentId); if (gettedRow.Count > 0) // If this item have childs then i print them { //Label1.Text += "<ul>"; foreach (var row in gettedRow) { emptylists.Item1.Add(row); if (row.ParentReceivedLetterOut != null && row.ParentReceivedLetterOut.Count > 0) { foreach (var row2 in row.ParentReceivedLetterOut) { emptylists.Item2.Add(row2); SendLetterManager mySendLetterManager = new SendLetterManager(); mySendLetterManager.GetChildItems(row2.Id, emptylists); } } GetChildItems(row.Id, emptylists); // Search for childs that belong to this item } } return(emptylists); }
public SendLetter GetParentOut(Guid child) { var parent = DBC.Database.SqlQuery <Guid>("SELECT ParentSendLetterOut_Id from ReceivedLetters where Id={0}", child) .FirstOrDefault(); SendLetterManager sendLetterManager = new SendLetterManager(); return(sendLetterManager.Read(parent)); }
//Logic to find Childrens of a parent public Tuple <List <ReceivedLetter>, List <SendLetter> > GetChildItems(Guid parentId, Tuple <List <ReceivedLetter>, List <SendLetter> > emptylists) { ReceivedLetter receivedLetter = Read(x => x.Id == parentId, null, "ParentReceivedLetterOut,ParentReceiveLetter").First(); if (receivedLetter != null) { emptylists.Item1.Add(receivedLetter); if (receivedLetter.ParentReceivedLetterOut != null && receivedLetter.ParentReceivedLetterOut.Count > 0) { foreach (var row2 in receivedLetter.ParentReceivedLetterOut) { emptylists.Item2.Add(row2); SendLetterManager mySendLetterManager = new SendLetterManager(); mySendLetterManager.GetChildItems(row2.Id, emptylists); } } GetChildItem(parentId, emptylists); //emptylists.Item2.AddRange(receivedLetter.ParentReceivedLetterOut); } return(emptylists); }