/////////////////////////////////////////////////////////// // TaskGroupTasks.cs // Implementation of Class TaskGroupTasks // CSLA type: Editable child collection // Created on: 07-Jun-2004 8:41:37 AM // Object design: John // Coded: John 29-July-2004 /////////////////////////////////////////////////////////// using System; using System.Data; using CSLA.Data; using CSLA; namespace GZTW.AyaNova.BLL { /// /// Editable child collectin of objects /// [Serializable] public class TaskGroupTasks : BusinessCollectionBase { #region Constructor //Private constructor prevents direction instantiation private TaskGroupTasks() { //Child MarkAsChild(); AllowSort=false; AllowFind=true; AllowEdit=true; AllowNew=true; AllowRemove=true; } #endregion #region Business properties and methods /// /// Retrieve TaskGroupTask by index /// /// Index public TaskGroupTask this[int Item] { get { return (TaskGroupTask) List[Item]; } } /// /// Retrieve TaskGroupTask by string containing Guid value /// public TaskGroupTask this[string TaskGroupTaskID] { get { System.Guid sid = new System.Guid(TaskGroupTaskID); foreach (TaskGroupTask child in List) { if(child.ID==sid) return child; } return null; } } /// /// Remove TaskGroupTask by passing it in /// /// public void Remove(TaskGroupTask obj) { List.Remove(obj); } /// /// Remove TaskGroupTask by string of id value /// /// public void Remove(string TaskGroupTaskID) { System.Guid sid = new System.Guid(TaskGroupTaskID); foreach (TaskGroupTask child in List) { if(child.ID==sid) List.Remove(child); } } /// /// Remove by Guid value of ID /// /// public void Remove(Guid TaskGroupTaskID) { foreach (TaskGroupTask child in List) { if(child.ID==TaskGroupTaskID) List.Remove(child); } } /// /// Add a new TaskGroupTask to the collection /// /// public TaskGroupTask Add(TaskGroup obj) { TaskGroupTask child=TaskGroupTask.NewItem(obj); List.Add(child); return child; } #endregion #region Contains /// /// Check if item in collection /// /// public bool Contains(TaskGroupTask obj) { foreach (TaskGroupTask child in List) { if(child.Equals(obj)) return true; } return false; } /// /// Check if item in collection by string of ID value /// /// public bool Contains(string TaskGroupTaskID) { System.Guid sid = new System.Guid(TaskGroupTaskID); foreach (TaskGroupTask child in List) { if(child.ID==sid) return true; } return false; } /// /// Check if item in deleted collection /// /// public bool ContainsDeleted(TaskGroupTask obj) { foreach (TaskGroupTask child in deletedList) { if(child.Equals(obj)) return true; } return false; } /// /// Check if item in deleted collection by string of ID value /// /// public bool ContainsDeleted(string TaskGroupTaskID) { System.Guid sid = new System.Guid(TaskGroupTaskID); foreach (TaskGroupTask child in deletedList) { if(child.ID==sid) return true; } return false; } #endregion #region Static methods /// /// NewItems /// /// internal static TaskGroupTasks NewItems() { return new TaskGroupTasks(); } /// /// GetItems /// /// /// internal static TaskGroupTasks GetItems(SafeDataReader dr) { TaskGroupTasks col = new TaskGroupTasks(); col.Fetch(dr); return col; } #endregion #region DAL DATA ACCESS /// /// Fetch children /// /// Populated data reader private void Fetch(SafeDataReader dr) { while(dr.Read()) { List.Add(TaskGroupTask.GetItem(dr)); } } /// /// Update children /// /// /// internal void Update(TaskGroup obj,IDbTransaction tr) { //update (thus deleting) any deleted child objects foreach (TaskGroupTask child in deletedList) { child.Update(obj,tr); } //Now that they are deleted remove them from memory deletedList.Clear(); foreach (TaskGroupTask child in List) { child.Update(obj,tr); } } #endregion }//end Tasks }//end namespace GZTW.AyaNova.BLL