public static DataSet Get24hrsSalesStockReportDataTable(string userID, DateTime fromDate, DateTime toDate, string branchCode) { ScopeRepository scopeRepository = new ScopeRepository(); // As we cannot instantiate a DbCommand because it is an abstract base class created from the repository with context connection. using DbCommand command = scopeRepository.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Usp_StockReport"; #region Parameters DbParameter UserID = command.CreateParameter(); UserID.Direction = ParameterDirection.Input; UserID.Value = (object)userID ?? DBNull.Value; UserID.ParameterName = "UserID"; DbParameter dbpBranchCode = command.CreateParameter(); dbpBranchCode.Direction = ParameterDirection.Input; dbpBranchCode.Value = (object)branchCode ?? DBNull.Value; dbpBranchCode.ParameterName = "branchCode"; DbParameter pmFromDate = command.CreateParameter(); pmFromDate.Direction = ParameterDirection.Input; pmFromDate.Value = (object)fromDate ?? DBNull.Value; pmFromDate.ParameterName = "fromDate"; DbParameter pmToDate = command.CreateParameter(); pmToDate.Direction = ParameterDirection.Input; pmToDate.Value = (object)toDate ?? DBNull.Value; pmToDate.ParameterName = "toDate"; #endregion // Add parameter as specified in the store procedure command.Parameters.Add(UserID); command.Parameters.Add(dbpBranchCode); command.Parameters.Add(pmFromDate); command.Parameters.Add(pmToDate); return(scopeRepository.ExecuteParamerizedCommand(command)); }
public async Task GetScopes_ScopesExist_ScopeIdIsAccurate() { // Arrange IScopeRepository scopeRepository = new ScopeRepository(new SQLServerGateway(), new ConnectionStringData()); // Act var scopes = await scopeRepository.GetAllScopes(); // Assert int i = 1; foreach (var scope in scopes) { if (scope.Id == i) { ++i; continue; } Assert.IsTrue(false); return; } Assert.IsTrue(true); }
public async Task UpdateScope_ScopeExists_ScopeNameIsAccurate(int id, string expectedUpdatedName, string expectedDescriptionName, bool expectedDefaultValue) { // Arrange IScopeRepository scopeRepository = new ScopeRepository(new SQLServerGateway(), new ConnectionStringData()); ScopeModel scopeModel = new ScopeModel(); scopeModel.Id = id; scopeModel.Type = expectedUpdatedName; scopeModel.Description = expectedDescriptionName; scopeModel.IsDefault = expectedDefaultValue; // Act await scopeRepository.UpdateScope(scopeModel); var actual = await scopeRepository.GetScopeById(id); var actualName = actual.Type; var actualDescriptionName = actual.Description; var actualDefaultValue = actual.IsDefault; // Assert Assert.IsTrue(actualName == expectedUpdatedName && actualDescriptionName == expectedDescriptionName && actualDefaultValue == expectedDefaultValue); }
public static DataTable GetEmployeeRegisterReportDataTable(string userID) { ScopeRepository scopeRepository = new ScopeRepository(); // As we cannot instantiate a DbCommand because it is an abstract base class created from the repository with context connection. using DbCommand command = scopeRepository.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Usp_GetEmployeeRegisterReport"; #region Parameters DbParameter UserID = command.CreateParameter(); UserID.Direction = ParameterDirection.Input; UserID.Value = (object)userID ?? DBNull.Value; UserID.ParameterName = "UserID"; #endregion // Add parameter as specified in the store procedure command.Parameters.Add(UserID); DataTable dt = scopeRepository.ExecuteParamerizedCommand(command).Tables[0]; if (dt.Rows.Count > 0) { return(dt); } else { return(null); } }
public ApiResourceUoW(ISessionManager sessionManager, ApiResourceRepository apiResourceRepository, ClaimTypeRepository claimTypeRepository, ScopeRepository scopeRepository) : base(sessionManager) { m_apiResourceRepository = apiResourceRepository; m_claimTypeRepository = claimTypeRepository; m_scopeRepository = scopeRepository; }
public virtual async Task <CurrencyViewModel> GetScopeCurrencyAsync(GetScopeCurrencyParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } var p = new GetScopeParam { Scope = param.Scope }; var scope = await ScopeRepository.GetScopeAsync(p).ConfigureAwait(false); CurrencyViewModel vm = null; if (scope?.Currency != null) { vm = ViewModelMapper.MapTo <CurrencyViewModel>(scope.Currency, param.CultureInfo); } return(vm); }
public ClientUoW(ISessionManager sessionManager, ClientRepository clientRepository, GrantTypeRepository grantTypeRepository, IdentityResourceRepository identityResourceRepository, ApiResourceRepository apiResourceRepository, ScopeRepository scopeRepository) : base(sessionManager) { m_clientRepository = clientRepository; m_grantTypeRepository = grantTypeRepository; m_identityResourceRepository = identityResourceRepository; m_apiResourceRepository = apiResourceRepository; m_scopeRepository = scopeRepository; }
private void dependency_OnChange(object sender, SqlNotificationEventArgs e) { SqlNotificationInfo s = e.Info; List <Scope> listScopes = ScopeRepository.GetAllCompletedScopes(); foreach (Scope obj in listScopes) { ScopeHub.Show(obj); } }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IScopeRepository scopeRepository = new ScopeRepository(dataGateway, connectionString); IResourceRepository resourceRepository = new ResourceRepository(dataGateway, connectionString); IClaimRepository claimRepository = new ClaimRepository(dataGateway, connectionString); IAccessPolicyRepository accessPolicyRepository = new AccessPolicyRepository(dataGateway, connectionString); IAccessPolicyPairingRepository accessPolicyPairingRepository = new AccessPolicyPairingRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { ResourceModel resourceModel = new ResourceModel(); resourceModel.Id = i; resourceModel.Name = "TestResource" + i; ScopeModel scopeModel = new ScopeModel(); scopeModel.Id = i; scopeModel.Type = "TestScope" + i; scopeModel.Description = "TestDescription" + i; ClaimModel claimModel = new ClaimModel(); claimModel.Id = i; claimModel.Type = "TestClaim" + i; claimModel.Value = "TestDescription" + i; claimModel.IsDefault = true; var resourceId = await resourceRepository.CreateResource(resourceModel); var claimId = await claimRepository.CreateClaim(claimModel); var scopeId = await scopeRepository.CreateScope(scopeModel); AccessPolicyModel accessPolicyModel = new AccessPolicyModel(); accessPolicyModel.Id = i; accessPolicyModel.Name = "TestAccessPolicy" + i; accessPolicyModel.ResourceId = resourceId; accessPolicyModel.Priority = i % 4; var accessPolicyId = await accessPolicyRepository.CreateAccessPolicy(accessPolicyModel); AccessPolicyPairingModel accessPolicyPairingModel = new AccessPolicyPairingModel(); accessPolicyPairingModel.Id = i; accessPolicyPairingModel.ScopeId = scopeId; accessPolicyPairingModel.ClaimId = claimId; accessPolicyPairingModel.AccessPolicyId = accessPolicyId; await accessPolicyPairingRepository.CreateAccessPolicyPairing(accessPolicyPairingModel); } }
private void InitializeScopeItem() { if (_scopeItem == null) { var p = new GetScopeParam { Scope = Scope }; _scopeItem = ScopeRepository.GetScopeAsync(p).ConfigureAwait(false).GetAwaiter().GetResult(); } }
public static DataTable GetDailySalesReportDataTable(string companyId, string branchName, string userName) { ScopeRepository scopeRepository = new ScopeRepository(); // As we cannot instantiate a DbCommand because it is an abstract base class created from the repository with context connection. using DbCommand command = scopeRepository.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Usp_GetDailySalesReport"; #region Parameters DbParameter pmcompanyId = command.CreateParameter(); pmcompanyId.Direction = ParameterDirection.Input; pmcompanyId.Value = (object)companyId ?? DBNull.Value; pmcompanyId.ParameterName = "companyId"; DbParameter pmbranchID = command.CreateParameter(); pmbranchID.Direction = ParameterDirection.Input; pmbranchID.Value = (object)branchName ?? DBNull.Value; pmbranchID.ParameterName = "branchCode"; DbParameter pmuserName = command.CreateParameter(); pmuserName.Direction = ParameterDirection.Input; pmuserName.Value = (object)userName ?? DBNull.Value; pmuserName.ParameterName = "userName"; DbParameter pmfDate = command.CreateParameter(); pmfDate.Direction = ParameterDirection.Input; pmfDate.Value = (object)DateTime.Now ?? DBNull.Value; pmfDate.ParameterName = "fDate"; DbParameter pmtDate = command.CreateParameter(); pmtDate.Direction = ParameterDirection.Input; pmtDate.Value = (object)DateTime.Now ?? DBNull.Value; pmtDate.ParameterName = "tDate"; #endregion // Add parameter as specified in the store procedure command.Parameters.Add(pmcompanyId); command.Parameters.Add(pmbranchID); command.Parameters.Add(pmfDate); command.Parameters.Add(pmtDate); command.Parameters.Add(pmuserName); DataTable dt = scopeRepository.ExecuteParamerizedCommand(command).Tables[0]; if (dt.Rows.Count > 0) { return(dt); } else { return(null); } }
public static void ConfigureScopes(IEnumerable<Scope> scopes, DocumentDbServiceOptions options) { ScopeRepository scopeRepository = new ScopeRepository(options.ToConnectionSettings()); var allScopes = scopeRepository.GetAllScopes().Result; if (!allScopes.Any()) { foreach (var s in scopes) { scopeRepository.AddScope(s.ToDocument()).Wait(); } } }
public static void ConfigureScopes(IEnumerable <Scope> scopes, DocumentDbServiceOptions options) { ScopeRepository scopeRepository = new ScopeRepository(options.CollectionNameResolver, options.ToConnectionSettings()); var allScopes = scopeRepository.GetAllScopes().Result; if (!allScopes.Any()) { foreach (var s in scopes) { scopeRepository.AddScope(s.ToDocument()).Wait(); } } }
public static void Show(Scope obj) { IHubContext context = GlobalHost.ConnectionManager.GetHubContext <ScopeHub>(); //context.Clients.All.updateMessages(); if (dxUsersConnections.ContainsKey(obj.UserId.ToString())) { List <string> availConnections = dxUsersConnections[obj.UserId.ToString()]; foreach (var connection in availConnections) { string jsonObject = JsonConvert.SerializeObject(obj); context.Clients.Client(connection).updateMessages(jsonObject); } ScopeRepository.UpdateScopeStatus(obj); } }
public void Scopes_IdentityResources_ReturnsExpectedScopes() { const string identityScope = "IdentityScope1"; var expectedScopes = new[] { "identityscope1" }; var identityResources = new[] { new IdentityResourceSetting { ResourceType = identityScope } }; var scopeRepository = new ScopeRepository(null, identityResources); var actualScopes = scopeRepository.Scopes; actualScopes.Should().BeEquivalentTo(expectedScopes); }
public static void Scopes_ApiResources_ReturnsExpectedScopes() { const string apiScope = "ApiScope1"; var expectedScopes = new[] { apiScope }; var apiResources = new[] { new ResourceSetting { ResourceName = apiScope } }; var scopeRepository = new ScopeRepository(apiResources, null); var actualScopes = scopeRepository.Scopes; actualScopes.Should().BeEquivalentTo(expectedScopes); }
public static void Scopes_ApiAndIdentityResources_ReturnsExpectedScopes() { const string scope1 = "Scope1"; const string scope2 = "Scope2"; var expectedScopes = new[] { scope1, "scope2" }; var apiResources = new[] { new ResourceSetting { ResourceName = scope1 } }; var identityResources = new[] { new IdentityResourceSetting { ResourceType = scope2 } }; var scopeRepository = new ScopeRepository(apiResources, identityResources); var actualScopes = scopeRepository.Scopes; actualScopes.Should().BeEquivalentTo(expectedScopes); }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IScopeRepository scopeRepository = new ScopeRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { ScopeModel scopeModel = new ScopeModel(); scopeModel.Id = i; scopeModel.Type = "TestScope" + i; scopeModel.Description = "TestDescription" + i; scopeModel.IsDefault = true; await scopeRepository.CreateScope(scopeModel); } }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IScopeRepository scopeRepository = new ScopeRepository(dataGateway, connectionString); IAssignmentPolicyRepository assignmentPolicyRepository = new AssignmentPolicyRepository(dataGateway, connectionString); IAssignmentPolicyPairingRepository assignmentPolicyPairingRepository = new AssignmentPolicyPairingRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { ScopeModel scopeModel = new ScopeModel(); scopeModel.Id = i; scopeModel.Type = "TestScope" + i; scopeModel.Description = "TestDescription" + i; var scopeId = await scopeRepository.CreateScope(scopeModel); scopeModel.IsDefault = true; AssignmentPolicyModel assignmentPolicyModel = new AssignmentPolicyModel(); assignmentPolicyModel.Id = i; assignmentPolicyModel.Name = "TestClaim" + i; assignmentPolicyModel.IsDefault = true; assignmentPolicyModel.RequiredAccountType = "TestAccountType" + i; assignmentPolicyModel.Priority = i % 4; var policyId = await assignmentPolicyRepository.CreateAssignmentPolicy(assignmentPolicyModel); AssignmentPolicyPairingModel assignmentPolicyPairingModel = new AssignmentPolicyPairingModel(); assignmentPolicyPairingModel.Id = i; assignmentPolicyPairingModel.PolicyId = policyId; assignmentPolicyPairingModel.ScopeId = scopeId; await assignmentPolicyPairingRepository.CreateAssignmentPolicyPairing(assignmentPolicyPairingModel); } }
public static string SalaryProcess(string Year, string Month, string CompanyCode, string EmpCode, string Status) { ScopeRepository scopeRepository = new ScopeRepository(); using DbCommand command = scopeRepository.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Salary_Process_EmpWise"; #region Parameters DbParameter year = command.CreateParameter(); DbParameter month = command.CreateParameter(); DbParameter companycode = command.CreateParameter(); DbParameter empCode = command.CreateParameter(); DbParameter status = command.CreateParameter(); year.Direction = ParameterDirection.Input; month.Direction = ParameterDirection.Input; companycode.Direction = ParameterDirection.Input; empCode.Direction = ParameterDirection.Input; status.Direction = ParameterDirection.Input; year.Value = (object)Year ?? DBNull.Value; month.Value = (object)Month ?? DBNull.Value; companycode.Value = (object)CompanyCode ?? DBNull.Value; empCode.Value = (object)EmpCode ?? DBNull.Value; status.Value = (object)Status ?? DBNull.Value; year.ParameterName = "pYear"; month.ParameterName = "pMonth"; companycode.ParameterName = "pCompanyCode"; empCode.ParameterName = "pEmpCode"; status.ParameterName = "pStatus"; #endregion // Add parameter as specified in the store procedure command.Parameters.Add(year); command.Parameters.Add(month); command.Parameters.Add(companycode); command.Parameters.Add(empCode); command.Parameters.Add(status); DataTable dt = scopeRepository.ExecuteParamerizedCommand(command).Tables[0]; return(null); }
public static DataSet getDataFromDataBase(List <parametersClass> dbParametersList, string procedureName) { DataSet ds = null; ScopeRepository scopeRepository = new ScopeRepository(); using (DbCommand command = scopeRepository.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = procedureName; #region Parameters foreach (parametersClass dbPar in dbParametersList) { DbParameter dbParameter = command.CreateParameter(); dbParameter.Direction = ParameterDirection.Input; dbParameter.Value = (object)dbPar.paramValue ?? DBNull.Value; dbParameter.ParameterName = dbPar.paramName; command.Parameters.Add(dbParameter); } #endregion ds = scopeRepository.ExecuteParamerizedCommand(command); } return(ds); }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IClaimRepository claimRepository = new ClaimRepository(dataGateway, connectionString); IScopeRepository scopeRepository = new ScopeRepository(dataGateway, connectionString); IScopeClaimRepository scopeClaimRepository = new ScopeClaimRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { ClaimModel claimModel = new ClaimModel(); claimModel.Id = i; claimModel.Type = "TestClaim" + i; claimModel.Value = "TestDescription" + i; claimModel.IsDefault = true; await claimRepository.CreateClaim(claimModel); } }
public static DataSet GetIntimateSaleReportDataSet(string ledgerCode, DateTime fromDate, DateTime toDate, string UserID) { ScopeRepository scopeRepository = new ScopeRepository(); // As we cannot instantiate a DbCommand because it is an abstract base class created from the repository with context connection. using DbCommand command = scopeRepository.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Usp_GetIntimateSaleReport"; #region Parameters DbParameter pmledgerCode = command.CreateParameter(); pmledgerCode.Direction = ParameterDirection.Input; pmledgerCode.Value = (object)ledgerCode ?? DBNull.Value; pmledgerCode.ParameterName = "ledgerCode"; DbParameter pmfDate = command.CreateParameter(); pmfDate.Direction = ParameterDirection.Input; pmfDate.Value = (object)fromDate ?? DBNull.Value; pmfDate.ParameterName = "fromDate"; DbParameter pmtDate = command.CreateParameter(); pmtDate.Direction = ParameterDirection.Input; pmtDate.Value = (object)toDate ?? DBNull.Value; pmtDate.ParameterName = "toDate"; DbParameter pmuserName = command.CreateParameter(); pmuserName.Direction = ParameterDirection.Input; pmuserName.Value = (object)UserID ?? DBNull.Value; pmuserName.ParameterName = "UserID"; #endregion // Add parameter as specified in the store procedure command.Parameters.Add(pmledgerCode); command.Parameters.Add(pmfDate); command.Parameters.Add(pmtDate); command.Parameters.Add(pmuserName); return(scopeRepository.ExecuteParamerizedCommand(command)); }
public async Task SeedUsers(int seedAmount) { await TestCleaner.CleanDatabase(); IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IListingRepository listingRepository = new ListingRepository(dataGateway, connectionString); ICollaborationRepository listingCollaborationRepository = new CollaborationRepository(dataGateway, connectionString); IRelationshipRepository listingRelationshipRepository = new RelationshipRepository(dataGateway, connectionString); ITeamModelRepository listingTeamModelRepository = new TeamModelRepository(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); IAssignmentPolicyRepository assignmentPolicyRepository = new AssignmentPolicyRepository(dataGateway, connectionString); IAssignmentPolicyPairingRepository assignmentPolicyPairingRepository = new AssignmentPolicyPairingRepository(dataGateway, connectionString); IScopeRepository scopeRepsitory = new ScopeRepository(dataGateway, connectionString); IClaimRepository claimRepository = new ClaimRepository(dataGateway, connectionString); IScopeClaimRepository scopeClaimRepository = new ScopeClaimRepository(dataGateway, connectionString); IUserScopeClaimRepository userScopeClaimRepository = new UserScopeClaimRepository(dataGateway, connectionString); IScopeService scopeService = new ScopeService(claimRepository, scopeRepsitory, scopeClaimRepository, userScopeClaimRepository); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAssignmentPolicyService assignmentPolicyService = new AssignmentPolicyService(assignmentPolicyRepository, assignmentPolicyPairingRepository, scopeRepsitory, scopeService); IClaimsService claimService = new ClaimsService(claimRepository, scopeRepsitory, scopeClaimRepository, userScopeClaimRepository); IListingCreationService listingCreationService = new ListingCreationService(listingRepository, listingCollaborationRepository, listingRelationshipRepository, listingTeamModelRepository); var accounts = await userAccountRepository.GetAllAccounts(); var accountSettings = await userAccountSettingsRepository.GetAllSettings(); IUserChannelsRepo userChannelsRepo = new UserChannelsRepo(dataGateway, connectionString); var userChannels = await userChannelsRepo.GetAllUserChannelsAsync(); foreach (var userChannel in userChannels) { await userChannelsRepo.DeleteUserChannelsByIdAsync(userChannel.Id); } await DataAccessTestHelper.ReseedAsync("UserChannels", 0, connectionString, dataGateway); IMessagesRepo messagesRepo = new MessagesRepo(dataGateway, connectionString); var messages = await messagesRepo.GetAllMessagesAsync(); foreach (var message in messages) { await messagesRepo.DeleteMessageByIdAsync(message.Id); } await DataAccessTestHelper.ReseedAsync("Messages", 0, connectionString, dataGateway); IChannelsRepo channelsRepo = new ChannelsRepo(dataGateway, connectionString); var channels = await channelsRepo.GetAllChannelsAsync(); foreach (var channel in channels) { await channelsRepo.DeleteChannelbyIdAsync(channel.Id); } IAccountVerificationRepo accountVerification = new AccountVerificationRepo(dataGateway, connectionString); var verfications = await accountVerification.GetAllAccountVerifications(); foreach (var verfication in verfications) { await accountVerification.DeleteAccountVerificationById(verfication.Id); } await DataAccessTestHelper.ReseedAsync("AccountVerification", 0, connectionString, dataGateway); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); var publicProfiles = await publicUserProfileRepo.GetAllPublicProfiles(); foreach (var profile in publicProfiles) { await publicUserProfileRepo.DeletePublicProfileById(profile.Id); } await DataAccessTestHelper.ReseedAsync("PublicUserProfile", 0, connectionString, dataGateway); if (accounts != null) { var numRows = accounts.ToList().Count; for (int i = 1; i <= numRows; ++i) { await userAccountSettingsRepository.DeleteUserAccountSettingsByUserId(i); } } await TestCleaner.CleanDatabase(); await DataAccessTestHelper.ReseedAsync("UserAccountSettings", 0, connectionString, dataGateway); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); var assignedScopes = new List <ScopeModel>(); var namedScopes = new List <string>() { "friends_list:read,", "friends_list:write,", "friends_list:delete,", "friends_list:block,", "friends_list:approve,", "user_profile:read,", "user_profile:report,", "user_profile:write,", "user_profile.friends_list.status:read,", "application:read,", "user_profile.visibility:read,", "user_profile.photo:upload,", "messaging:send,", "messaging:get,", "messaging.users:get,", "messaging.channels:addUser,", "messaging.channels:removeUser,", "channels.user:getall,", "channels:create,", "channels:getowner,", "channels:delete,", "message:delete,", "channel:setonline,", "channel:setoffline,", "account:delete,", "account:passwordchange,", "account.fontszie:change,", "account.email:change,", "account.fontSize:get,", "account.fontstyle:change,", "account.fontstyle:get,", "account.theme:change,", "account.theme:get,", "listings:read,", "listings:write," }; var claims = new List <ClaimModel>(); claims.Add(new ClaimModel() { Type = "channel_owner", Value = "false", IsDefault = true }); claims.Add(new ClaimModel() { Type = "Moderator", Value = "false", IsDefault = true }); var currentClaims = await claimService.GetAllClaims(); foreach (var claim in claims) { foreach (var currentClaim in currentClaims) { if (claim.Type == currentClaim.Type) { continue; } } await claimService.CreateClaim(claim); } var databaseClaims = await claimService.GetAllClaims(); foreach (var scope in namedScopes) { assignedScopes.Add(new ScopeModel() { Type = scope, Claims = databaseClaims, Description = null, IsDefault = true }); } assignedScopes.ForEach(async x => await scopeService.CreateScope(x)); var scopes = (await scopeService.GetAllScopes()).ToList(); var assignmentPolicies = await assignmentPolicyService.CreateAssignmentPolicy(new BusinessModels.UserAccessControl.AssignmentPolicyModel() { Default = true, Name = "DefaultAccessPolicy", AssignedScopes = scopes, Priority = 1, RequiredAccountType = "user" }); var adminPolicies = await assignmentPolicyService.CreateAssignmentPolicy(new BusinessModels.UserAccessControl.AssignmentPolicyModel() { Default = true, Name = "DefaultAdminPolicy", AssignedScopes = scopes, Priority = 1, RequiredAccountType = "admin" }); PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(new PublicUserProfileService(publicUserProfileRepo, new ValidationService(userAccountService, userProfileService))); IAccountVerificationRepo accountVerificationRepo = new AccountVerificationRepo(new SQLServerGateway(), new ConnectionStringData()); IDictionary <string, string> _testConfigKeys = new Dictionary <string, string>(); _testConfigKeys.Add("Sender", "*****@*****.**"); _testConfigKeys.Add("TrackOpens", "true"); _testConfigKeys.Add("Subject", "Welcome!"); _testConfigKeys.Add("TextBody", "Welcome to InfiniMuse!"); _testConfigKeys.Add("MessageStream", "outbound"); _testConfigKeys.Add("Tag", "Welcome"); _testConfigKeys.Add("HtmlBody", "Thank you for registering! Please confirm your account with the link: <a href='{0}'>Confirm Your Account!</a><strong>Once confirmed you will have access to the features.</strong>"); IConfiguration configuration = new ConfigurationBuilder() .AddInMemoryCollection(_testConfigKeys) .Build(); EmailService emailService = new EmailService(new UserAccountRepository (new SQLServerGateway(), new ConnectionStringData()), new AccountVerificationRepo (new SQLServerGateway(), new ConnectionStringData()), new UserAccountService(new UserAccountRepository (new SQLServerGateway(), new ConnectionStringData())), configuration); for (int i = 1; i < seedAmount; ++i) { UserAccountModel userAccountModel = new UserAccountModel(); UserProfileModel userProfileModel = new UserProfileModel(); UserAccountSettingsModel userAccountSettingsModel = new UserAccountSettingsModel(); userAccountModel.Id = i; userAccountModel.Username = "******" + i; userAccountModel.Password = "" + i; userAccountModel.Salt = "" + i; userAccountModel.EmailAddress = "TestEmailAddress" + i; userAccountModel.AccountType = "user"; userAccountModel.AccountStatus = "TestAccountStatus" + i; userAccountModel.CreationDate = DateTimeOffset.UtcNow; userAccountModel.UpdationDate = DateTimeOffset.UtcNow; userProfileModel.Id = i; userProfileModel.FirstName = "TestFirstName" + i; userProfileModel.Surname = "TestSurname" + i; userProfileModel.DateOfBirth = DateTimeOffset.UtcNow; userProfileModel.UserAccountId = userAccountModel.Id; userAccountSettingsModel.Id = i; userAccountSettingsModel.UserId = userAccountModel.Id; userAccountSettingsModel.FontSize = 12; userAccountSettingsModel.FontStyle = "Default"; userAccountSettingsModel.ThemeColor = "Light"; await userAccountRepository.CreateAccount(userAccountModel); await cryptographyService.newPasswordEncryptAsync("T" + i, i); await userProfileRepository.CreateUserProfile(userProfileModel); await userAccountSettingsRepository.CreateUserAccountSettings(userAccountSettingsModel); PublicUserProfileModel publicUserProfileModel = new PublicUserProfileModel(); publicUserProfileModel.UserId = userAccountModel.Id; publicUserProfileModel.Description = "My name is " + userAccountModel.Username; publicUserProfileModel.Visibility = "Public"; publicUserProfileModel.Age = userAccountModel.Id + 20; publicUserProfileModel.Hobbies = "These are my hobbies"; publicUserProfileModel.Intrests = "These are my intrests"; publicUserProfileModel.Height = "This is how tall I am"; await publicUserProfileManager.CeatePublicUserProfileAsync(publicUserProfileModel); await emailService.CreateVerificationToken(publicUserProfileModel.UserId); } IMessagingService messagingService = new MessagingService(messagesRepo, channelsRepo, userChannelsRepo, userAccountRepository); ChannelModel model = new ChannelModel(); model.OwnerId = 1; model.Name = "Jakes Group"; await messagingService.CreateChannelAsync(model); for (int i = 2; i < 19; i++) { await messagingService.AddUserToChannelAsync(i, 1); } IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString); IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString); IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString); IEnumerable <FriendsListJunctionModel> friends = await friendListRepo.GetAllFriends(); foreach (var friend in friends) { await friendListRepo.DeleteFriendListbyId(friend.Id); } await DataAccessTestHelper.ReseedAsync("FriendsList", 0, connectionString, dataGateway); IEnumerable <FriendsListJunctionModel> requets = await friendRequestListRepo.GetAllFriendRequests(); foreach (var request in requets) { await friendRequestListRepo.DeleteFriendRequestListbyId(request.Id); } await DataAccessTestHelper.ReseedAsync("FriendRequestList", 0, connectionString, dataGateway); IEnumerable <FriendsListJunctionModel> blocks = await friendBlockListRepo.GetAllFriendBlocks(); foreach (var block in blocks) { await friendBlockListRepo.DeleteFriendBlockbyId(block.Id); } await DataAccessTestHelper.ReseedAsync("FriendBlockList", 0, connectionString, dataGateway); for (int i = 0; i < 20; i++) { BusinessCollaborationModel newBusinessCollaborationModel = new BusinessCollaborationModel(); BusinessListingModel newBusinessListingModel = new BusinessListingModel(); newBusinessCollaborationModel.Title = "TestTitle" + i; newBusinessCollaborationModel.Details = "TestDetails" + i; newBusinessCollaborationModel.City = "TestCity" + i; newBusinessCollaborationModel.State = "TestState" + i; newBusinessCollaborationModel.NumberOfParticipants = i; newBusinessCollaborationModel.InPersonOrRemote = "InpersonOrRemoteTest" + i; newBusinessCollaborationModel.UserAccountId = i; newBusinessCollaborationModel.CollaborationType = "TestcollaborationType" + i; newBusinessCollaborationModel.InvolvementType = "InvolvementType" + i; newBusinessCollaborationModel.Experience = "Testexperience" + i; newBusinessCollaborationModel.CollaborationType = "TestCollaborationType" + i; newBusinessCollaborationModel.InvolvementType = "TestInvolvementType" + i; newBusinessCollaborationModel.Experience = "TestExperience" + i; await listingCreationService.CreateListing(newBusinessCollaborationModel); } for (int i = 21; i < 40; i++) { BusinessRelationshipModel newBusinessRelationshipModel = new BusinessRelationshipModel(); BusinessListingModel newBusinessListingModel1 = new BusinessListingModel(); newBusinessRelationshipModel.Title = "TestTitle" + i; newBusinessRelationshipModel.Details = "TestDetails" + i; newBusinessRelationshipModel.City = "TestCity" + i; newBusinessRelationshipModel.State = "TestState" + i; newBusinessRelationshipModel.NumberOfParticipants = i; newBusinessRelationshipModel.InPersonOrRemote = "InpersonOrRemoteTest" + i; newBusinessRelationshipModel.UserAccountId = i; newBusinessRelationshipModel.RelationshipType = "TestcollaborationType" + i; newBusinessRelationshipModel.Age = 21; newBusinessRelationshipModel.Interests = "TestInterests" + i; newBusinessRelationshipModel.GenderPreference = "TestGenderPreference" + i; await listingCreationService.CreateListing(newBusinessRelationshipModel); } for (int i = 41; i < 60; i++) { BusinessTeamModel newBusinessTeamModel = new BusinessTeamModel(); BusinessListingModel newBusinessListingModel1 = new BusinessListingModel(); newBusinessTeamModel.Title = "TestTitle" + i; newBusinessTeamModel.Details = "TestDetails" + i; newBusinessTeamModel.City = "TestCity" + i; newBusinessTeamModel.State = "TestState" + i; newBusinessTeamModel.NumberOfParticipants = i; newBusinessTeamModel.InPersonOrRemote = "InpersonOrRemoteTest" + i; newBusinessTeamModel.UserAccountId = i + 1; newBusinessTeamModel.TeamType = "TestTeamType" + i; newBusinessTeamModel.GameType = "TestGameType" + i; newBusinessTeamModel.Platform = "TestPlatform" + i; newBusinessTeamModel.Experience = "TestExperience" + i; await listingCreationService.CreateListing(newBusinessTeamModel); } IUserReportsRepo userReportsRepo = new UserReportsRepo(dataGateway, connectionString); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo, friendListRepo, friendRequestListRepo, userReportsRepo, validationService); IFriendListManager friendListManager = new FriendListManager(userAccountRepository, publicUserProfileService, userInteractionService); for (int i = 10; i < 15; i++) { await friendListManager.RequestFriendAsync(1, i); } await friendListManager.RequestFriendAsync(18, 1); for (int i = 2; i < 10; i++) { await friendListManager.RequestFriendAsync(1, i); await friendListManager.ConfirmFriendAsync(1, i); } for (int i = 3; i < 10; i++) { await friendListManager.RequestFriendAsync(2, i); await friendListManager.ConfirmFriendAsync(2, i); } await friendListManager.BlockFriendAsync(19, 1); MessageModel messageModel = new MessageModel(); messageModel.ChannelId = 1; messageModel.UserId = 1; messageModel.Message = "Hi Tim"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 1; messageModel.UserId = 2; messageModel.Message = "Whats up Jake"; await messagingService.SendMessageAsync(messageModel); model = new ChannelModel(); model.OwnerId = 3; model.Name = "Richards Group"; await messagingService.CreateChannelAsync(model); await messagingService.AddUserToChannelAsync(1, 2); await messagingService.AddUserToChannelAsync(2, 2); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 3; messageModel.Message = "Hi Jake and Tim"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 1; messageModel.Message = "Whats up Richard how are you doing"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 3; messageModel.Message = "Im Chilling"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 3; messageModel.Message = "Just doing some homework"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 1; messageModel.Message = "Oh nice, I started spring break this week and I finished all of my homework a few days ago so im just relaxing playing some warzone"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 3; messageModel.Message = "Oh sweet"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 2; messageModel.Message = "Whats up guys its me Tim"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 3; messageModel.Message = "Hey Tim"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 1; messageModel.Message = "Whats up tim"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 2; messageModel.Message = "Nothing much guys"; await messagingService.SendMessageAsync(messageModel); messageModel = new MessageModel(); messageModel.ChannelId = 2; messageModel.UserId = 1; messageModel.Message = "You guys wanna hop on warzone with me"; await messagingService.SendMessageAsync(messageModel); }
public ScopeRepositoryTests() { _repo = new ScopeRepository(TestFactory.SharedCollection, TestFactory.CreateConnectionSettings()); RepoUtil.Reset(_repo); }
public static async Task CleanDatabase() { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(dataGateway, connectionString); IResourceRepository resourceRepository = new ResourceRepository(dataGateway, connectionString); IClaimRepository claimRepository = new ClaimRepository(dataGateway, connectionString); IScopeRepository scopeRepository = new ScopeRepository(dataGateway, connectionString); IScopeClaimRepository scopeClaimRepository = new ScopeClaimRepository(dataGateway, connectionString); IUserScopeRepository userScopeRepository = new UserScopeRepository(dataGateway, connectionString); IUserClaimRepository userClaimRepository = new UserClaimRepository(dataGateway, connectionString); IAssignmentPolicyRepository assignmentPolicyRepository = new AssignmentPolicyRepository(dataGateway, connectionString); IAssignmentPolicyPairingRepository assignmentPolicyPairingRepository = new AssignmentPolicyPairingRepository(dataGateway, connectionString); IUserScopeClaimRepository userScopeClaimRepository = new UserScopeClaimRepository(dataGateway, connectionString); IAccessPolicyRepository accessPolicyRepository = new AccessPolicyRepository(dataGateway, connectionString); IAccessPolicyPairingRepository accessPolicyPairingRepository = new AccessPolicyPairingRepository(dataGateway, connectionString); ITraditionalListingSearchRepository traditionalListingSearchRepository = new TraditionalListingSearchRepository(dataGateway, connectionString); var accounts = await userAccountRepository.GetAllAccounts(); var profiles = await userProfileRepository.GetAllUserProfiles(); var accountCodes = await userAccountCodeRepository.GetAllUserAccountCodes(); var accountSettings = await userAccountSettingsRepository.GetAllSettings(); var loginAttempts = await loginAttemptsRepository.GetAllLoginAttempts(); var resources = await resourceRepository.GetAllResources(); var claims = await claimRepository.GetAllClaims(); var scopes = await scopeRepository.GetAllScopes(); var scopeClaims = await scopeClaimRepository.GetAllScopeClaims(); var userClaims = await userClaimRepository.GetAllUserClaims(); var userScopes = await userScopeRepository.GetAllUserScopes(); var assignmentPolicies = await assignmentPolicyRepository.GetAllAssignmentPolicies(); var assignmentPolicyPairings = await assignmentPolicyPairingRepository.GetAllAssignmentPolicyPairings(); var userScopeClaims = await userScopeClaimRepository.GetAllUserScopeClaims(); var accessPolicies = await accessPolicyRepository.GetAllAccessPolicies(); var accesssPolicyPairings = await accessPolicyPairingRepository.GetAllAccessPoliciesPairings(); var listings = await traditionalListingSearchRepository.GetAllListings(); var collaborationListings = await traditionalListingSearchRepository.GetAllCollaborationListings(); var relationshipListings = await traditionalListingSearchRepository.GetAllRelationshipListings(); var teamListings = await traditionalListingSearchRepository.GetAllTeamListings(); if (resources != null) { await DeleteAllFromTable("Resource"); await ReseedAsync("Resource", 0, connectionString, dataGateway); } if (claimRepository != null) { await DeleteAllFromTable("Claim"); await ReseedAsync("Claim", 0, connectionString, dataGateway); } if (scopeRepository != null) { await DeleteAllFromTable("Scope"); await ReseedAsync("Scope", 0, connectionString, dataGateway); } if (scopeClaims != null) { await DeleteAllFromTable("ScopeClaim"); await ReseedAsync("ScopeClaim", 0, connectionString, dataGateway); } if (assignmentPolicies != null) { await DeleteAllFromTable("AssignmentPolicy"); await ReseedAsync("AssignmentPolicy", 0, connectionString, dataGateway); } if (assignmentPolicyPairings != null) { await DeleteAllFromTable("AssignmentPolicyPairing"); } if (userScopeClaims != null) { await DeleteAllFromTable("UserScopeClaim"); await ReseedAsync("UserScopeClaim", 0, connectionString, dataGateway); } if (userScopes != null) { await DeleteAllFromTable("UserScope"); await ReseedAsync("UserScope", 0, connectionString, dataGateway); } if (userClaims != null) { await DeleteAllFromTable("UserClaim"); await ReseedAsync("UserClaim", 0, connectionString, dataGateway); } if (accessPolicies != null) { await DeleteAllFromTable("AccessPolicy"); await ReseedAsync("AccessPolicy", 0, connectionString, dataGateway); } if (accesssPolicyPairings != null) { await DeleteAllFromTable("AccessPolicyPairing"); await ReseedAsync("AssignmentPolicyPairing", 0, connectionString, dataGateway); await ReseedAsync("AccessPolicyPairing", 0, connectionString, dataGateway); } if (loginAttempts != null) { await DeleteAllFromTable("LoginAttempts"); await ReseedAsync("LoginAttempts", 0, connectionString, dataGateway); } if (accounts != null) { await DeleteAllFromTable("UserProfile"); await DeleteAllFromTable("UserAccountSettings"); await DeleteAllFromTable("UserAccountCode"); await DeleteAllFromTable("UserAccount"); await ReseedAsync("UserAccount", 0, connectionString, dataGateway); await ReseedAsync("UserProfile", 0, connectionString, dataGateway); await ReseedAsync("UserAccountCode", 0, connectionString, dataGateway); await ReseedAsync("UserAccountSettings", 0, connectionString, dataGateway); } if (listings != null) { await DeleteAllFromTable("Listing"); await ReseedAsync("Listing", 0, connectionString, dataGateway); } if (collaborationListings != null) { await DeleteAllFromTable("Collaboration"); await ReseedAsync("Collaboration", 0, connectionString, dataGateway); } if (relationshipListings != null) { await DeleteAllFromTable("Relationship"); await ReseedAsync("Relationship", 0, connectionString, dataGateway); } if (teamListings != null) { await DeleteAllFromTable("TeamModel"); await ReseedAsync("TeamModel", 0, connectionString, dataGateway); } }
public ScopeRepositoryTests() { _repo = new ScopeRepository(ConnectionSettingsFactory.Create()); RepoUtil.Reset(_repo); }