private void ResolveStatus(Member currentMember) { Statuses currentUserStatus = ATACore.Managers.MemberManager.GetMemberStatus(currentMember); ATACore.RegistryManager.WriterCurrentUserToRegistry(currentMember.UserName); SettingsAppearanceViewModel aSettings = new SettingsAppearanceViewModel(); switch (currentUserStatus) { case Statuses.Active: ResetValidationMessage(); MemberRoles currentRole = ATACore.Managers.MemberRoleManager.GetMemberRoleByUserName(ATACore.Managers.ContextManager.Context, MemberProxy.UserName); ATACore.Managers.ContextManager.Context.Dispose(); if (currentRole.Equals(MemberRoles.Admin)) DisplayAdminWindow(); else DisplayAfterLoginActiveUserWindow(); break; case Statuses.ToBeApproved: DisplayValidationMessage(ToBeApprovedMessage); break; case Statuses.PendingActivation: DisplayActivationWindow(); break; default: break; } }
private void SendActivationEmail(Member memberToBeApproved) { var message = new MailMessage(); message.To.Add(memberToBeApproved.Email); var client = new SmtpClient(); message.Body = memberToBeApproved.ActivationCodes.Last(x => x.Code != null).Code; client.Send(message); }
private static void AddTeamsToNewMember(ATAEntities context, List<string> teams, Member newMember) { teams.ForEach(t => { Team currentTeam = ATACore.Managers.TeamManager.GetTeamByName(context, t); newMember.Teams.Add(currentTeam); }); }
public Member CreateUser(ATAEntities context, string userName, string password, string email, string tfsUserName, string role, List<string> teams, string comment) { string hashedPassword = CreatePasswordHash(password); MemberRole currentMemberRole = ATACore.Managers.MemberRoleManager.GetMemberRoleByRoleName(context, role); Member newMember = new Member() { UserName = userName, Password = hashedPassword, Email = email, Comment = comment, TfsUserName = tfsUserName, MemberRoleId = currentMemberRole.MemberRoleId }; newMember.StatusId = (int)Statuses.ToBeApproved; AddTeamsToNewMember(context, teams, newMember); context.Members.Add(newMember); context.SaveChanges(); return newMember; }
public Statuses GetMemberStatus(Member member) { Statuses status = (Statuses)member.StatusId; return status; }