public void Copy(Group g) { if (g == null) { throw new ArgumentNullException("g"); } this.Id = g.Id; this.Name = g.Name; this.Description = g.Description; }
public Principal Find(string query) { #region argument checking if (string.IsNullOrEmpty(query)) { throw new ArgumentNullException("query"); } #endregion Principal principal = null; SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = @"Proc_Ratna_Principal_Find"; AddParameter(command, "@SiteId", SqlDbType.Int, Jardalu.Ratna.Core.WebContext.Current.Site.Id); AddParameter(command, "@Query", SqlDbType.NVarChar, query); SqlParameter errorCodeParameter = AddOutputParameter(command, "@ErrorCode", SqlDbType.BigInt); using (SqlConnection sqlConnection = new SqlConnection(ConnectionInformation.Instance.ConnectionString)) { using (command) { command.Connection = sqlConnection; command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { bool isGroup = (bool)reader["IsGroup"]; long principalId = (long)reader["PrincipalId"]; string name = reader["Name"] as string; if (isGroup) { principal = new Group() { Name=name, PrincipalId = principalId }; } else { principal = new User() { Name = name, PrincipalId = principalId }; } } if (!reader.IsClosed) { reader.Close(); } } } //read the error code long errorCode = (long)errorCodeParameter.Value; if (errorCode != NoErrorCode) { ThrowError(errorCode); } return principal; }