private List <dynamic> getKidsChurchChild(KidsChurch kidsChurch) { List <dynamic> dynamicKidsChurches = new List <dynamic>(); try { foreach (Person_Children kidsChurchChild in kidsChurch.Person_Children) { dynamic dynamicKidsChurchChild = new ExpandoObject(); dynamicKidsChurchChild.KidsChurchID = kidsChurchChild.KidsChurchID; dynamicKidsChurchChild.PersonID = kidsChurchChild.PersonID; dynamicKidsChurchChild.ChildID = kidsChurchChild.ChildID; dynamicKidsChurchChild.KCVolunteerConfirmation = kidsChurchChild.KCVolunteerConfirmation; dynamicKidsChurchChild.CheckIn = kidsChurchChild.CheckIn; dynamicKidsChurchChild.CheckInDateTime = kidsChurchChild.CheckInDateTime; dynamicKidsChurchChild.SignOut = kidsChurchChild.SignOut; dynamicKidsChurchChild.SignOutDateTime = kidsChurchChild.SignOutDateTime; dynamicKidsChurches.Add(dynamicKidsChurchChild); } } catch (Exception e) { } return(dynamicKidsChurches); }
public List <dynamic> ChildByParentID(Person personID) //get JSON parameter { //validate that there is no null values if (personID != null) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //establish database connection db.Configuration.ProxyCreationEnabled = false; //configure proxy to eliminate overload of data List <Person_Children> childInfo = db.Person_Children.Where(x => x.PersonID == personID.PersonID && x.KidsChurch != null && x.CheckIn == false).ToList(); List <dynamic> childInfoList = new List <dynamic>(); try { foreach (Person_Children ParentChild in childInfo) { Child childNameInfo = db.Children.Where(x => x.ChildID == ParentChild.ChildID).FirstOrDefault(); KidsChurch kidschurchName = db.KidsChurches.Where(x => x.KidsChurchID == ParentChild.KidsChurchID).FirstOrDefault(); dynamic child = new ExpandoObject(); child.ChildID = childNameInfo.ChildID; child.Name = childNameInfo.Name; child.Surname = childNameInfo.Surname; child.KidsChurchName = kidschurchName.KidsChurchName; childInfoList.Add(child); } } catch (Exception) { return(null); } return(childInfoList); // return called method } else { return(null); } }
public List <dynamic> getChildConfirmation(List <dynamic> childinfo) { //Validate that there are no null values if (childinfo != null) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminate overload db.Configuration.ProxyCreationEnabled = false; List <dynamic> childInfoList = new List <dynamic>(); try { foreach (Person_Children pchild in childinfo) { Child childNameInfo = db.Children.Where(x => x.ChildID == pchild.ChildID).FirstOrDefault(); KidsChurch kidschurchName = db.KidsChurches.Where(x => x.KidsChurchID == pchild.KidsChurchID).FirstOrDefault(); dynamic dynamicChild = new ExpandoObject(); dynamicChild.ChildID = childNameInfo.ChildID; dynamicChild.Name = childNameInfo.Name; dynamicChild.Surname = childNameInfo.Surname; dynamicChild.KidsChurchName = kidschurchName.KidsChurchName; childInfoList.Add(dynamicChild); } } catch (Exception) { return(null); } return(childInfoList); // return called method } else { return(null); } }
public List <dynamic> MyChildren([FromBody] Person parent) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminamte overload of memory db.Configuration.ProxyCreationEnabled = false; //Create dynamic list List <dynamic> Children = new List <dynamic>(); List <dynamic> dynamicMyChildren = new List <dynamic>(); //Check if the parent passed through as parameter is null and if the parent is found, the parent's children should also be found if (parent == null) { return(null); } else { //Create list of parent to find the parent currently loggend in with their ID List <Person_Children> myChildren = db.Person_Children.Include(y => y.KidsChurch).Where(x => x.PersonID == parent.PersonID).ToList(); try { //Loop through the list of parents found and find the children with the matching PersonID and the Kids Church of the child with the matching KidsChurchID foreach (var c in myChildren) { Child cc = db.Children.Where(o => o.ChildID == c.ChildID).FirstOrDefault(); KidsChurch kc = db.KidsChurches.Where(i => i.KidsChurchID == c.KidsChurchID).FirstOrDefault(); //Create dynamic object to find the child information to be returned dynamic child = new ExpandoObject(); child.ChildID = cc.ChildID; child.Name = cc.Name; child.Surname = cc.Surname; child.DateOfBirth = cc.DateOfBirth; //child.KidsChurchName = kc.KidsChurchName; if (kc == null) { child.KidsChurchName = "Not yet registered"; } else { child.KidsChurchName = kc.KidsChurchName; } if (cc == null && kc == null) { dynamicMyChildren.Add(child); } else { //Add dynamic object created to the dynamic list Children.Add(child); } } } catch (Exception) { return(null); } } //Return the dynamic list return(Children.Concat(dynamicMyChildren).ToList()); }