public UserInfo GetEncryptedInfo() { UserInfo info = new UserInfo() { Id = Id, Name = Name, RegDate = RegDate, EmailIsVisible = EmailIsVisible, TestsCompleted = 0, TestsCreated = 0, Email = Email }; if (TestResults != null) { info.TestsCompleted = TestResults.Count(); } if (Tests != null) { info.TestsCreated = Tests.Count(); } if (!EmailIsVisible) { string tmp = new string(Email.TakeWhile(c => c != '@').ToArray()); int count = 2; if (tmp.Length < 4) { count = 1; } if (tmp.Length == 1) { count = 0; } tmp = new string(tmp.Take(count).ToArray()) + new string('*', tmp.Length - count); info.Email = tmp + new string(Email.SkipWhile(c => c != '@').ToArray()); } info.Password = new string('*', 6); return(info); }