public SyncPaymentHelper() { Logger = LogFactory.GetLogger(typeof(SyncPaymentHelper)); serviceTaskProviderConfiguration = (ServiceTaskProviderConfigurationSection)ConfigurationManager.GetSection(ConfigurationConstants.CONFIG_KEY_DATA_PROVIDER_SECTION); businessDao = new BusinessDao(); businessManager = new BusinessManager(); serviceClient = new PaymentServiceServiceClient(); SetMerchantAccountsConfigurationList(); }
/// <summary> /// Sets up a user for each business that doesn't have a user extension entry /// Then adds the user extension entry for the user id / business id /// Also adds each of the created users to the business role /// </summary> private static void SetUpUserExtensionsForBusinessesInDatabase() { //Get all of the businesses BusinessDao businessDao = new BusinessDao(); UserExtensionDao userExtensionDao = new UserExtensionDao(); List<Business> businesses = businessDao.GetAll(); MembershipCreateStatus didItCreate; MembershipUser createdUser; List<UserExtension> userExtensionsAlreadyCreated = userExtensionDao.GetAll(); //role name for business string businessRole = "BusinessUser"; List<string> usersNeedingBusinessRole = new List<string>(); foreach (Business business in businesses) { string currentUserName = business.BusinessShortName + "User"; // Check if the user is in the business role if (Roles.IsUserInRole(currentUserName, businessRole) == false) { usersNeedingBusinessRole.Add(currentUserName); } // check if the user is already created if (userExtensionsAlreadyCreated.Exists(ue => ue.PrimaryBusinessId == business.Id)) { continue; } createdUser = Membership.CreateUser(currentUserName, "p@ssw0rd", "testerWithBusinessId_" + business.Id.ToString() + "@eviivo.com", "the answer is A", "A", true, out didItCreate); // If it was a dupe, get the user and use it to add the extension if (didItCreate == MembershipCreateStatus.DuplicateUserName) { //Already exists so get the id from the db createdUser = Membership.GetUser(currentUserName); } // This isn't all that helpful, just prevents user extension adds that aren't correct else if (didItCreate != MembershipCreateStatus.Success) { break; } userExtensionDao.Create((Guid)createdUser.ProviderUserKey, business.Id, (Guid)createdUser.ProviderUserKey); } if (usersNeedingBusinessRole.Count > 0) { Roles.AddUsersToRole(usersNeedingBusinessRole.ToArray(), businessRole); } }
public void GetBusinessesModifiedAfter() { // Arrange using (new TestDataHelper(GetTestQuery(TestQuery.PopulateSearchBusinessesTestData), GetTestQuery(TestQuery.CleanupUnitTestData))) { //// Arrange var businessDao = new BusinessDao(); DateTime date = DateTime.Now.AddYears(-1); //// Act var result = businessDao.GetLastModifiedBusinesses(date); Assert.IsNotNull(result, "Business list returned was null"); Assert.IsTrue(result.Any(), "No businesses were returned"); } }