public InsertCompanyStatus InsertUser(int companyId, User user, Profile profile, int? depositId) { // // If ProfileId equal 0 then the profile no exists in bd // var pManager = new ProfileManager(this); if (profile.ProfileId == 0) pManager.Insert(profile); // //method to insert a new user // var provider = Membership.Provider as VivinaMembershipProvider; MembershipCreateStatus status; var membershipManager = new MembershipManager(this); user.ProfileId = profile.ProfileId; membershipManager.Insert(user, out status, provider.RequiresValidEmail); // //verify if the status of the inclusion is ok // if (status != MembershipCreateStatus.Success) { DataManager.Rollback(); switch (status) { case MembershipCreateStatus.InvalidPassword: return InsertCompanyStatus.InvalidPassword; case MembershipCreateStatus.DuplicateEmail: return InsertCompanyStatus.DuplicatedAdminEmail; } } // // Associate the User with company // AssociateUser(companyId, user.UserId, depositId, true); // // Insert a Employee // var humanResourcesManager = new HumanResourcesManager(this); var employee = new Employee(); employee.IsActive = true; employee.ProfileId = profile.ProfileId; employee.CompanyId = companyId; humanResourcesManager.InsertEmployee(employee, new List<EmployeeAdditionalInformation>()); return InsertCompanyStatus.Success; }