public User() { Id = -1; Enabled = true; EtUser = new EtalonUser(); AdGroups = new List<AdGroup>(); }
public static User GetUserBySid(string sid) { User user; SqlParameter pSid = new SqlParameter() { ParameterName = "user_sid", Value = sid, DbType = DbType.AnsiString }; DataTable dt = ExecuteQueryStoredProcedure(sp, "getUserBySid", pSid); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; int id = (int)dr["id_user"]; string login = dr["login"].ToString(); string userSid = dr["sid"].ToString(); string fullName = dr["full_name"].ToString(); string displayName = dr["display_name"].ToString(); string mail = dr["mail"].ToString(); bool enabled = (bool)dr["enabled"]; if (String.IsNullOrEmpty(displayName)) displayName = fullName; user = new User(id, login, fullName, displayName, mail) { Enabled = enabled, AdSid = userSid }; SqlParameter pUserId = new SqlParameter() { ParameterName = "id_user", Value = user.Id, DbType = DbType.Int32 }; dt = ExecuteQueryStoredProcedure(sp, "getEtUserByUserId", pUserId); EtalonUser etUser; if (dt.Rows.Count > 0) { dr = dt.Rows[0]; int etId = (int)dr["id_et_user"]; string etLogin = dr["et_login"].ToString(); string etPassword = dr["et_password"].ToString(); string etDisplayName = dr["et_display_name"].ToString(); string adSid = dr["ad_sid"].ToString(); etUser = new EtalonUser(etId, etLogin, etPassword, etDisplayName) { AdSid = adSid }; } else { string etDisplayName = "Не зарегистрирован"; etUser = new EtalonUser() { DisplayName = etDisplayName }; } user.EtUser = etUser; } else { user = new User(); } return user; }