/// <summary> /// Updates the list access. /// </summary> /// <param name="ListId">The list id.</param> /// <param name="ListAccess">The list access.</param> public static void UpdateListAccess(int ListId, DataTable ListAccess) { if (!CanAdmin(ListId)) { throw new AccessDeniedException(); } using (DbTransaction tran = DbTransaction.Begin()) { DBListInfo.DeleteListAccessByList(ListId); foreach (DataRow row in ListAccess.Rows) { int PrincipalId = (int)row["PrincipalId"]; byte AllowLevel = (byte)row["AllowLevel"]; if (AllowLevel < 1 || AllowLevel > 3) { throw new ArgumentOutOfRangeException("AllowLevel", AllowLevel, "should be > 0 and < 3"); } DBListInfo.CreateListAccess(ListId, PrincipalId, AllowLevel); } tran.Commit(); } }
/// <summary> /// Gets the list accesses as DataTable. /// </summary> /// <param name="ListId">The list id.</param> /// <returns>ListAccessId, PrincipalId, AllowLevel</returns> public static DataTable GetListAccessesDT(int ListId) { if (!CanAdmin(ListId)) { throw new AccessDeniedException(); } return(DBListInfo.GetListAccessesDT(ListId)); }
/// <summary> /// Gets the list accesses as IDataReader. /// </summary> /// <param name="ListId">The list id.</param> /// <returns>ListAccessId, PrincipalId, AllowLevel</returns> public static IDataReader GetListAccesses(int ListId) { if (!CanAdmin(ListId)) { throw new AccessDeniedException(); } return(DBListInfo.GetListAccesses(ListId)); }
/// <summary> /// Gets the security for user. /// </summary> /// <param name="ListId">The list id.</param> /// <param name="UserId">The user id.</param> /// <returns></returns> public static int GetSecurityForUser(int listId, int userId) { int retVal = 0; string key = string.Format(CultureInfo.InvariantCulture, "_list_{0}_usr_{1}", listId, userId); if (HttpContext.Current == null || HttpContext.Current.Items[key] == null) { retVal = DBListInfo.GetSecurityForUser(listId, userId); if (HttpContext.Current != null) { HttpContext.Current.Items[key] = retVal; } } else { retVal = (int)HttpContext.Current.Items[key]; } return(retVal); }
/// <summary> /// Deletes the list access by PrincipalId. /// </summary> /// <param name="listId">The list id.</param> /// <param name="principalId">The principal id.</param> public static void DeleteListAccess(int listId, int principalId) { DBListInfo.DeleteListAccess(listId, principalId); }
/// <summary> /// Deletes the list access by list. /// </summary> /// <param name="ListId">The list id.</param> public static void DeleteListAccessByList(int ListId) { DBListInfo.DeleteListAccessByList(ListId); }
/// <summary> /// Creates the list access. /// </summary> /// <param name="ListId">The list id.</param> /// <param name="PrincipalId">The principal id.</param> /// <param name="AllowLevel">The allow level.</param> /// <returns></returns> public static int CreateListAccess(int ListId, int PrincipalId, byte AllowLevel) { return(DBListInfo.CreateListAccess(ListId, PrincipalId, AllowLevel)); }
/// <summary> /// Gets the list access. /// </summary> /// <param name="ListAccessId">The list access id.</param> /// <returns>ListId, PrincipalId, AllowLevel</returns> public static IDataReader GetListAccess(int ListAccessId) { return(DBListInfo.GetListAccess(ListAccessId)); }