public static PageAuthentication GetPageAuthentication(Page Page) { PageAuthentication result = new PageAuthentication(); result._Page = Page; PagePermissionCollection PagePermissionList = PagePermissionCollection.GetPagePermissionCollection(); foreach (PagePermission item in PagePermissionList) { result._listAuthentication.Add(item, new List<Role>()); } RoleCollection roleList = RoleCollection.GetRoleCollection(); Database database = new Database("PSCPortalConnectionString"); using (DbConnection connection = database.GetConnection()) { DbCommand command = database.GetCommand(connection); #region PageId DbParameter prPageId = database.GetParameter(System.Data.DbType.Guid, "@PageId", Page.Id); command.Parameters.Add(prPageId); #endregion command.CommandText = "PageAuthentication_GetAllByPageId"; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); DbDataReader reader = command.ExecuteReader(); int idtptemp; Guid idrtemp; PagePermission tptemp; Role rtemp; while (reader.Read()) { idtptemp = (int)reader["PagePermissionId"]; idrtemp = (Guid)reader["RoleId"]; tptemp = PagePermissionList.Where(tp => tp.Id == idtptemp).Single(); rtemp = roleList.Where(r => r.Id == idrtemp).Single(); result._listAuthentication[tptemp].Add(rtemp); } } return result; }
public static PagePermissionCollection GetPagePermissionCollection() { PagePermissionCollection result = new PagePermissionCollection(); Database database = new Database("PSCPortalConnectionString"); using (DbConnection connection = database.GetConnection()) { DbCommand command = database.GetCommand(connection); command.CommandText = "PagePermission_GetAll"; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { result.Add(new PagePermission(reader)); } } } return(result); }