///////////////////////////////////////////////////////////
// RegionWoStatusNotifyItems.cs
// Implementation of Class RegionWoStatusNotifyItems
// CSLA type: Editable child collection
// Created on: 21-Dec-2010
// Object design: John
// Coded: John 21-Dec-2010
///////////////////////////////////////////////////////////
using System;
using CSLA.Data;
using CSLA;
using System.Data;
namespace GZTW.AyaNova.BLL
{
///
/// Editable child collection of objects assigned to
///
[Serializable]
public class RegionWoStatusNotifyItems : BusinessCollectionBase {
#region Constructor
//Private constructor prevents direction instantiation
private RegionWoStatusNotifyItems()
{
//Child
MarkAsChild();
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
///
/// Retrieve RegionWoStatusNotifyItem by index
///
/// Index
public RegionWoStatusNotifyItem this[int Item]
{
get
{
return (RegionWoStatusNotifyItem) List[Item];
}
}
///
/// Retrieve RegionWoStatusNotifyItem by string containing Guid value
///
public RegionWoStatusNotifyItem this[string sID]
{
get
{
System.Guid sid = new System.Guid(sID);
foreach (RegionWoStatusNotifyItem child in List)
{
if(child.ID==sid)
return child;
}
return null;
}
}
///
/// Remove RegionWoStatusNotifyItem by passing it in
///
///
public void Remove(RegionWoStatusNotifyItem obj)
{
List.Remove(obj);
}
///
/// Remove RegionWoStatusNotifyItem by string of id value
///
///
public void Remove(string sID)
{
System.Guid sid = new System.Guid(sID);
foreach (RegionWoStatusNotifyItem child in List)
{
if(child.ID==sid)
List.Remove(child);
}
}
///
/// Remove by Guid value of ID
///
///
public void Remove(Guid ID)
{
foreach (RegionWoStatusNotifyItem child in List)
{
if(child.ID==ID)
List.Remove(child);
}
}
///
/// Add a new RegionWoStatusNotifyItem to the collection
///
///
public RegionWoStatusNotifyItem Add(Region obj)
{
RegionWoStatusNotifyItem child=RegionWoStatusNotifyItem.NewItem(obj);
List.Add(child);
return child;
}
#endregion
#region Contains
///
/// Check if item in collection
///
///
public bool Contains(RegionWoStatusNotifyItem obj)
{
foreach (RegionWoStatusNotifyItem 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 sID)
{
System.Guid sid = new System.Guid(sID);
foreach (RegionWoStatusNotifyItem child in List)
{
if(child.ID==sid) return true;
}
return false;
}
///
/// Check if item in deleted collection
///
///
public bool ContainsDeleted(RegionWoStatusNotifyItem obj)
{
foreach (RegionWoStatusNotifyItem 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 sID)
{
System.Guid sid = new System.Guid(sID);
foreach (RegionWoStatusNotifyItem child in deletedList)
{
if(child.ID==sid) return true;
}
return false;
}
#endregion
#region Static methods
///
/// NewItems
///
///
internal static RegionWoStatusNotifyItems NewItems()
{
return new RegionWoStatusNotifyItems();
}
////case 1186
//internal static RegionWoStatusNotifyItems GetItems(SafeDataReader dr)
//{
// return GetItems(dr, false);
//}
///
///
///
///
///
internal static RegionWoStatusNotifyItems GetItems(SafeDataReader dr)
{
//if (AyaBizUtils.Right("Object.Region") > (int)SecurityLevelTypes.ReadOnly)
//{
RegionWoStatusNotifyItems col = new RegionWoStatusNotifyItems();
col.Fetch(dr);
return col;
//}
//else
// throw new System.Security.SecurityException(
// string.Format(
// LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
// LocalizedTextTable.GetLocalizedTextDirect("O.Region")));
}
#endregion
#region DAL DATA ACCESS
///
/// Fetch children
///
/// Populated data reader
private void Fetch(SafeDataReader dr)
{
while(dr.Read())
{
List.Add(RegionWoStatusNotifyItem.GetItem(dr));
}
}
///
/// Update children
///
///
internal void Update(IDbTransaction tr)
{
//update (thus deleting) any deleted child objects
foreach (RegionWoStatusNotifyItem child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (RegionWoStatusNotifyItem child in List)
{
child.Update(tr);
}
}
#endregion
}//end RegionWoStatusNotifyItems
}//end namespace GZTW.AyaNova.BLL