143 lines
3.8 KiB
C#
143 lines
3.8 KiB
C#
// ========================================================================
|
|
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
|
|
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
|
// ------------------------------------------------------------------------
|
|
// $Workfile: $ $Revision: $
|
|
// $Author: $ $Date: $
|
|
//
|
|
// $History: $
|
|
// ========================================================================
|
|
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using Csla;
|
|
using Csla.Data;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
|
|
namespace Volian.CSLA.Library
|
|
{
|
|
/// <summary>
|
|
/// RoleAssignments Generated by MyGeneration using the CSLA Object Mapping template
|
|
/// </summary>
|
|
[Serializable()]
|
|
public partial class RoleAssignments : BusinessListBase<RoleAssignments, RoleAssignment>
|
|
{
|
|
#region Business Methods
|
|
private string _errorMessage = string.Empty;
|
|
public string ErrorMessage
|
|
{
|
|
get { return _errorMessage; }
|
|
}
|
|
// Many To Many
|
|
public RoleAssignment this[int folderID, int gid]
|
|
{
|
|
get
|
|
{
|
|
foreach (RoleAssignment assignment in this)
|
|
if (assignment.FolderID == folderID && assignment.GID == gid)
|
|
return assignment;
|
|
return null;
|
|
}
|
|
}
|
|
public RoleAssignment GetItem(int folderID, int gid)
|
|
{
|
|
foreach (RoleAssignment assignment in this)
|
|
if (assignment.FolderID == folderID && assignment.GID == gid)
|
|
return assignment;
|
|
return null;
|
|
}
|
|
public RoleAssignment Add(int gid, int folderID)
|
|
{
|
|
if (!Contains(gid, folderID))
|
|
{
|
|
RoleAssignment assignment = RoleAssignment.New(gid, folderID);
|
|
this.Add(assignment);
|
|
return assignment;
|
|
}
|
|
else
|
|
throw new InvalidOperationException("assignment already exists");
|
|
}
|
|
public void Remove(int folderID, int gid)
|
|
{
|
|
foreach (RoleAssignment assignment in this)
|
|
{
|
|
if (assignment.FolderID == folderID && assignment.GID == gid)
|
|
{
|
|
Remove(assignment);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
public bool Contains(int folderID, int gid)
|
|
{
|
|
foreach (RoleAssignment assignment in this)
|
|
if (assignment.FolderID == folderID && assignment.GID == gid)
|
|
return true;
|
|
return false;
|
|
}
|
|
public bool ContainsDeleted(int folderID, int gid)
|
|
{
|
|
foreach (RoleAssignment assignment in DeletedList)
|
|
if (assignment.FolderID == folderID && assignment.GID == gid)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
#region Factory Methods
|
|
internal static RoleAssignments New()
|
|
{
|
|
return new RoleAssignments();
|
|
}
|
|
internal static RoleAssignments Get(SafeDataReader dr)
|
|
{
|
|
return new RoleAssignments(dr);
|
|
}
|
|
private RoleAssignments()
|
|
{
|
|
MarkAsChild();
|
|
}
|
|
private RoleAssignments(SafeDataReader dr)
|
|
{
|
|
MarkAsChild();
|
|
Fetch(dr);
|
|
}
|
|
#endregion
|
|
#region Data Access Portal
|
|
// called to load data from the database
|
|
private void Fetch(SafeDataReader dr)
|
|
{
|
|
this.RaiseListChangedEvents = false;
|
|
while (dr.Read())
|
|
this.Add(RoleAssignment.Get(dr));
|
|
this.RaiseListChangedEvents = true;
|
|
}
|
|
internal void Update(Role role, SqlConnection cn)
|
|
{
|
|
this.RaiseListChangedEvents = false;
|
|
try
|
|
{
|
|
// update (thus deleting) any deleted child objects
|
|
foreach (RoleAssignment obj in DeletedList)
|
|
obj.DeleteSelf(role, cn);
|
|
// now that they are deleted, remove them from memory too
|
|
DeletedList.Clear();
|
|
// add/update any current child objects
|
|
foreach (RoleAssignment obj in this)
|
|
{
|
|
if (obj.IsNew)
|
|
obj.Insert(role, cn);
|
|
else
|
|
obj.Update(role, cn);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
this.RaiseListChangedEvents = true;
|
|
}
|
|
}
|
|
#endregion
|
|
} // Class
|
|
} // Namespace
|