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