///////////////////////////////////////////////////////////
// AssignedDocs.cs
// Implementation of Class AssignedDocs
// CSLA type: Editable child collection
// Created on: 15-April-2005
// Object design: John
// Coded: John 15-April-2005
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
///
/// Collection of items
///
[Serializable]
public class AssignedDocs : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private AssignedDocs()
{
//Child
MarkAsChild();
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
///
/// Retrieve AssignedDoc by index
///
/// Index
public AssignedDoc this[int Item]
{
get
{
return (AssignedDoc) List[Item];
}
}
///
/// Retrieve AssignedDoc by string containing Guid value
///
public AssignedDoc this[string AssignedDocID]
{
get
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in List)
{
if(child.ID==sid)
return child;
}
return null;
}
}
///
/// Remove AssignedDoc by passing it in
///
///
public void Remove(AssignedDoc obj)
{
List.Remove(obj);
}
///
/// Remove AssignedDoc by string of id value
///
///
public void Remove(string AssignedDocID)
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in List)
{
if(child.ID==sid)
List.Remove(child);
}
}
///
/// Remove by Guid value of ID
///
///
public void Remove(Guid AssignedDocID)
{
foreach (AssignedDoc child in List)
{
if(child.ID==AssignedDocID)
List.Remove(child);
}
}
///
/// Add a new AssignedDoc to the collection
///
///
///
///
public AssignedDoc Add(RootObjectTypes type, Guid ID, RootObjectTypes ExactObjectType) //case 1584
{
AssignedDoc child=AssignedDoc.NewItem(type, ExactObjectType);
child.RootObjectID=ID;
child.RootObjectType=type;
List.Add(child);
return child;
}
#endregion
#region Contains
///
/// Check if item in collection
///
///
public bool Contains(AssignedDoc obj)
{
foreach (AssignedDoc 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 AssignedDocID)
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in List)
{
if(child.ID==sid) return true;
}
return false;
}
///
/// Check if item in deleted collection
///
///
public bool ContainsDeleted(AssignedDoc obj)
{
foreach (AssignedDoc 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 AssignedDocID)
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in deletedList)
{
if(child.ID==sid) return true;
}
return false;
}
#endregion
#region Static methods
///
/// NewItems
///
///
internal static AssignedDocs NewItems()
{
return new AssignedDocs();
}
///
/// GetItems
///
internal static AssignedDocs GetItems(SafeDataReader dr, RootObjectTypes type, RootObjectTypes ExactObjectType)//case 1584
{
AssignedDocs col = new AssignedDocs();
col.Fetch(dr, type, ExactObjectType);
return col;
}
#endregion
#region DAL DATA ACCESS
///
/// Fetch children
///
private void Fetch(SafeDataReader dr, RootObjectTypes type, RootObjectTypes ExactObjectType)//case 1584
{
while(dr.Read())
{
List.Add(AssignedDoc.GetItem(dr,type, ExactObjectType));
}
}
///
/// Update children
///
///
internal void Update(IDbTransaction tr)
{
//update (thus deleting) any deleted child objects
foreach (AssignedDoc child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (AssignedDoc child in List)
{
child.Update(tr);
}
}
#endregion
}//end Tasks
}//end namespace GZTW.AyaNova.BLL