private GetStarted StartNewProspect() { var user = AccountHelper.GetUserAccount(HttpContext); Int32 callCenterId = 0; if (user.Roles != null && user.Roles.OrderByDescending(r => r.RolePriority).FirstOrDefault() != null) { if (user.Roles.OrderByDescending(r => r.RolePriority).FirstOrDefault().RoleName.Equals(RoleName.LoanProcessor)) { callCenterId = user.UserAccountId; } } string message; Int32 createdUserAccountId; // Create account string username = "******" + DateTime.Now.ToString("MMddyyyyHmmss") + "@meandmyloan.com"; var newUserAccount = new UserAccount() { Username = username, DateCreated = DateTime.Now, IsActivated = false, IsLocked = false, IsTemporary = false, Password = String.Empty, PasswordHint = String.Empty, SecurityAnswer = String.Empty, SecurityQuestionId = 1, OpenedByLOorConcierge = true, CreationStatus = UserAccountCreationStatus.SystemGenerated, IsOnlineUser = true, // by default we create online user, this will be changed on CreateAccountLO page Party = new Party() { FirstName = "new", LastName = "prospect", SSN = "000-00-0000 ", MiddleName = String.Empty, CompanyName = String.Empty, EmailAddress = String.Empty, AlternateEmailAddress = String.Empty }, }; var hierarchy = new BrandingConfigurationHierarchy() { BranchId = user.BranchId == Guid.Empty ? null : ( Guid? )user.BranchId, ChannelId = user.ChannelId == 0 ? null : ( int? )user.ChannelId, DivisionId = user.DivisionId == 0 ? null : ( int? )user.DivisionId }; var brandingConfiguration = CompanyProfileServiceFacade.RetrieveBrandingConfigurationByHierarchy(hierarchy); if (UserAccountServiceFacade.CreateUserAccount(newUserAccount, false, out message, out createdUserAccountId, brandingConfiguration, createdByUserId: user.UserAccountId) == false) { throw new ApplicationException("Error creating new user account"); } if (createdUserAccountId < 0) { throw new ApplicationException("Error creating new user account"); } newUserAccount.UserAccountId = createdUserAccountId; // Create Contact var contact = new Contact { FirstName = "new", LastName = "prospect", UserAccount = newUserAccount, LoanId = null, OwnerAccountId = user.UserAccountId, IsInitialLead = true, }; if (brandingConfiguration != null) { contact.CompanyProfileId = brandingConfiguration.CompanyProfileId; contact.ChannelId = brandingConfiguration.ChannelId; contact.DivisionId = brandingConfiguration.DivisionId; contact.BranchId = brandingConfiguration.BranchId; } if (callCenterId != 0) { contact.CallCenterId = callCenterId; } var createdContact = ContactServiceFacade.CreateContact(contact); // Create impersonation token Guid token = MML.Common.Impersonation.ImpersonationToken.GetToken(); bool isInserted = ImpersonationTokenServiceFacade.InsertImpersonationToken(token, Guid.Empty, user.UserAccountId); if (isInserted) { GetStartedHelper getStartedHelper = new GetStartedHelper(); return(getStartedHelper.GetStarted(HttpContext, user, token, username, true, createdContact.ContactId, isTempUser: true)); } return(null); }