public EmailVerifier(AccountConfiguration config, AccountRepository repo) { if (config == null) throw new ArgumentNullException("config"); this.config = config; this.repo = new AccountRepositoryWrapper(config.RequireDependency(repo)); }
public string AddCustomerToAccount(Guid accountId, CustomerDto customerDto) { try { Guid personId = customerDto.PersonId; AccountRepository repository = new AccountRepository(); Person person = repository.ActiveContext.Persons.Where(p => p.Id == personId).FirstOrDefault(); if (person == null) return ("the person id is invalid and customer can't be find"); Account account = repository.ActiveContext.BankAccounts.OfType<Account>() .Include("customers.Person") .Where(a => a.Id == accountId) .FirstOrDefault(); if (account == null) return "account id is invalid and can not be find"; if (!account.ContainCustomer(personId)) { Customer customer = Customer.CreateCustomer(person, customerDto.No, customerDto.Portion); account.Customers = new Collection<Customer>(); account.Customers.Add(customer); repository.ActiveContext.SaveChanges(); return "customer added successfully"; } return "customer was there in database"; } catch (Exception fException) { return fException.Message; } }
public void LogOn() { // Arrange - database /*Mock<AccountRepository> mock = new Mock<AccountRepository>(); mock.Setup(u => u.Save(new Account { ID = 1, Email = "*****@*****.**", Password = "******", FirstName = "Mr.", LastName = "Whatever", Role = 2, CreatedDate = DateTime.Now }));*/ IAccountRepository accountRepository = new AccountRepository(); accountRepository.Save(new Account { ID = 1, Email = "*****@*****.**", FirstName = "Admin", LastName = "von Världsklass", Password = "******", Salt = "oh yeah", Administrator = true, CreatedDate = DateTime.Now }); accountRepository.Save(new Account { ID = 2, Email = "*****@*****.**", FirstName = "Bokare", LastName = "von Världsklass", Password = "******", Salt = "good salt", Administrator = false, CreatedDate = DateTime.Now }); // Arrange - viewmodel LogOnViewModel model = new LogOnViewModel { Email = "*****@*****.**", Password = "******" }; // Arrange - controller AccountController controller = new AccountController(accountRepository); // Act ActionResult result = controller.LogOn(model, "/") as ActionResult; // Assert Assert.IsInstanceOfType(result, typeof(RedirectResult)); Assert.AreEqual("/", ((RedirectResult)result).Url); }
public ActionResult LogIn(string Email, string Password) { try { if (ModelState.IsValid) { AccountRepository _repository = new AccountRepository(); Account _account = new Account(); _account = _repository.GetAccount(Email, Password); if (_account != null) { Session.Add("Account", _account); return RedirectToAction("Index", "Home"); } else { TempData["AlertLogin"] = "******"; return RedirectToAction("Index", "Access"); } } return View(); } catch (System.Exception) { TempData["AlertLogin"] = "******"; return View("Index", "Access"); } }
public void Cannot_delete_account_that_does_not_exist() { var account = _account1; IAccountRepository repository = new AccountRepository(); repository.Remove(account); repository.Remove(account); }
public void AccountRepository() { Mock<IWebsiteContext> context = new Mock<IWebsiteContext>(); Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Account>> dbSet = new Mock<DbSet<Account>>(); factory.Setup(m => m.CreateDbSet<Account>()).Returns(dbSet.Object); AccountRepository repo = new AccountRepository(context.Object, factory.Object); var account = new Account { Id = "SDF", FullName = "Trevor Slawnyk", PreferredName = "Trevor", Zip = 68456, FacebookId = 4929447011515, Birthdate = new DateTime(1994, 6, 22), Weight = 250, Height = 73, Sex = false }; account.UserName = "******"; var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(account)); dbSet.InSequence(sequence).Setup(e => e.Find(account.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(account.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(account.Id)); repo.Create(account); repo.Get(account.Id); repo.Update(account); repo.Delete(account.Id); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); AccountRepository _repo = new AccountRepository(new PokerContext()); //using (AccountRepository _repo = new AccountRepository(new PokerContext())) { UserModel user = await _repo.FindUser(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); //identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, context.ClientId)); identity.AddClaim(new Claim("role", "user")); context.Validated(identity); }
public UserModel GetUser(string username, string password) { UserModel userModel = new UserModel(); AccountRepository accountRepository = new AccountRepository(); try { var user = accountRepository.Get(username); if (user.Password.Equals(password)) { userModel.Id = user.Id; userModel.CritizenId = user.CritizenId; userModel.BirthDay = user.BirthDay; userModel.UserName = user.UserName; userModel.FirstName = user.FirstName; userModel.LastName = user.LastName; userModel.Password = user.Password; userModel.Email = user.Email; userModel.Address = user.Address; userModel.ZipCode = user.ZipCode; userModel.UserClassId = user.UserClass.Id; userModel.UserClassName = user.UserClass.UserClassName; return userModel; } else { return null; } } catch (Exception e) { return null; } return null; }
public AccountController(UserManager<User> userManager, SignInManager<User> signInManager, CloudContext context, AccountRepository repository) { _userManager = userManager; _signInManager = signInManager; Repository = repository; CloudContext = context; }
public ActionResult Account() { AccountRepository accrepo = new AccountRepository(); User _user = (User)Session["User"]; //_user.EmailId = "*****@*****.**"; List<Account> objaccount = accrepo.getAccountDetails(_user.EmailId); ViewBag.accountlist = objaccount; return View(); }
public PasswordChanger(AccountConfiguration config, IAccountContext context, AccountRepository repo, PasswordService passServ) { if (config == null) throw new ArgumentNullException("config"); if (context == null) throw new ArgumentNullException("context"); this.context = context; this.repo = new AccountRepositoryWrapper(config.RequireDependency(repo)); this.passServ = config.RequireDependency(passServ); }
public EmailChanger(AccountConfiguration config, IAccountContext context, AccountRepository repo, PasswordService passwordService, FormsAuthenticationService formsAuthService) { if (config == null) throw new ArgumentNullException("config"); if (context == null) throw new ArgumentNullException("context"); this.config = config; this.context = context; this.repo = new AccountRepositoryWrapper(config.RequireDependency(repo)); this.passServ = config.RequireDependency(passwordService); this.formsAuthService = config.RequireDependency(formsAuthService); }
public UnitOfWork(RaisinsDB raisinsDb) { _raisinsDb = raisinsDb; Beneficiaries = new BeneficiaryRepository(_raisinsDb); Accounts = new AccountRepository(_raisinsDb); Activities = new ActivityRepository(_raisinsDb); Currencies = new CurrencyRepository(_raisinsDb); Payments = new PaymentRepository(_raisinsDb); MailQueues = new MailQueuesRepository(_raisinsDb); Executives = new ExecutiveRepository(_raisinsDb); }
/// <summary> /// Creates an <see cref="IAccountRepository"/> /// </summary> /// <returns></returns> public IAccountRepository CreateRepository() { // create repository var repository = new AccountRepository(); // turn off lazy-loading repository.Configuration.LazyLoadingEnabled = false; // return the repository return repository; }
public void Can_delete_existing_account() { var account = _account1; IAccountRepository repository = new AccountRepository(); repository.Remove(account); using (ISession session = SessionFactory.OpenSession()) { var fromDb = session.Get<Account>(account.Id); Assert.IsNull(fromDb); } }
public AutoResolveClientDbContext() { conn = DependencyService.Get<ISQLite>().GetConnection(); CustomerRepository = new CustomerRepository(conn); AccidentRepository = new AccidentRepository(conn); WitnessRepository = new WitnessRepository(conn); OtherDriverRepository = new OtherDriverRepository(conn); MediaRepository = new AccidentMediaRepository(conn); CustomerSettingsRepository = new CustomerSettingsRepository(conn); AccountRepository = new AccountRepository(conn); }
public HttpResponseMessage Authenticate([FromBody]AuthenticationAccountModel model) { return SafeAction(() => { using (var repository = new AccountRepository()) { var id = repository.Authenticate(model.Username, model.Password, model.Remember); CacheCookieProvider.CreateCookie(id).SetCookie(); FormsAuthentication.SetAuthCookie(model.Username, model.Remember); return Request.CreateResponse(HttpStatusCode.OK, GetUserStateInfo(true, model.Username, id)); } }, model); }
public void InsertDeleteAndUpdateTest() { var ClientRepository = new ClientRepository(_unitOfWork); Client customer = ClientRepository.FindByID(10); customer.Name = "Updated"; ClientRepository.Update(customer); var accountRepository = new AccountRepository(_unitOfWork); var accountList = accountRepository.GetCustomerAccounts(customer.ClientID); foreach (var account in accountList) { accountRepository.Remove(account); } _unitOfWork.Commit(); var deletedAccountList = accountRepository.GetCustomerAccounts(customer.ClientID); Assert.AreEqual(0, deletedAccountList.Count); }
public static void Delete_User_Create_In_Feature() { TestRunHelper.Session.BeginTransaction(); var repo = new AccountRepository(TestRunHelper.Session); var users = repo.GetBy(x => x.UserName == "someuser"); if (users != null) { foreach (var user in users) { repo.Delete(user); } } TestRunHelper.Session.Transaction.Commit(); }
public async Task CreateAsync(AuthenticationTokenCreateContext context) { try { var clientid = context.Ticket.Properties.Dictionary["as:client_id"]; if (string.IsNullOrEmpty(clientid)) { return; } var refreshTokenId = Guid.NewGuid().ToString("n"); using (AccountRepository _repo = new AccountRepository(new MyRoomDbContext())) { var refreshTokenLifeTime = context.OwinContext.Get<string>("as:clientRefreshTokenLifeTime"); var token = new RefreshToken() { Id = Helper.GetHash(refreshTokenId), ClientId = clientid, Subject = context.Ticket.Identity.Name, IssuedUtc = DateTime.UtcNow, ExpiresUtc = DateTime.UtcNow.AddMinutes(Convert.ToDouble(refreshTokenLifeTime)) }; context.Ticket.Properties.IssuedUtc = token.IssuedUtc; context.Ticket.Properties.ExpiresUtc = token.ExpiresUtc; token.ProtectedTicket = context.SerializeTicket(); var result = await _repo.AddRefreshToken(token); if (result) { context.SetToken(refreshTokenId); } } } catch (Exception ex) { throw ex; } }
public void ActivateAccount(Guid accountId, string activationCode) { if (string.IsNullOrEmpty(activationCode)) throw new ArgumentNullException("activationCode"); using (AccountRepository accountRepository = new AccountRepository()) { var account = accountRepository.Get(accountId); if (account != null) account.Activate(activationCode); else { // throw custermized exception throw new AccountNotExistException(Resource.ResourceMessage.ex_AccountIsNotExist); } accountRepository.Commit(); } }
private void Loadaccounts() { accountRepository = new AccountRepository(); var allAccounts = accountRepository.GetAll().ToList(); accountlistbindingSource.DataSource = allAccounts; //if (CurrentUser.AccountUsers != null) //{ // var accounts = from c in CurrentUser.AccountUsers select c.Account; // foreach (var account in accounts) // { // if (accounts.Where(a => a.AccountID == account.AccountID).Count() > 0) // { // var a = allAccounts.SingleOrDefault(c => c.AccountID == account.AccountID); // allAccounts.Remove(a); // } // } //} }
public OctopusRepository(IOctopusClient client) { this.Client = client; Feeds = new FeedRepository(client); Backups = new BackupRepository(client); Machines = new MachineRepository(client); MachineRoles = new MachineRoleRepository(client); MachinePolicies = new MachinePolicyRepository(client); Subscriptions = new SubscriptionRepository(client); Environments = new EnvironmentRepository(client); Events = new EventRepository(client); FeaturesConfiguration = new FeaturesConfigurationRepository(client); ProjectGroups = new ProjectGroupRepository(client); Projects = new ProjectRepository(client); Proxies = new ProxyRepository(client); Tasks = new TaskRepository(client); Users = new UserRepository(client); VariableSets = new VariableSetRepository(client); LibraryVariableSets = new LibraryVariableSetRepository(client); DeploymentProcesses = new DeploymentProcessRepository(client); Releases = new ReleaseRepository(client); Deployments = new DeploymentRepository(client); Certificates = new CertificateRepository(client); Dashboards = new DashboardRepository(client); DashboardConfigurations = new DashboardConfigurationRepository(client); Artifacts = new ArtifactRepository(client); Interruptions = new InterruptionRepository(client); ServerStatus = new ServerStatusRepository(client); UserRoles = new UserRolesRepository(client); Teams = new TeamsRepository(client); RetentionPolicies = new RetentionPolicyRepository(client); Accounts = new AccountRepository(client); Defects = new DefectsRepository(client); Lifecycles = new LifecyclesRepository(client); OctopusServerNodes = new OctopusServerNodeRepository(client); Channels = new ChannelRepository(client); ProjectTriggers = new ProjectTriggerRepository(client); Schedulers = new SchedulerRepository(client); Tenants = new TenantRepository(client); TagSets = new TagSetRepository(client); BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client); ActionTemplates = new ActionTemplateRepository(client); CommunityActionTemplates = new CommunityActionTemplateRepository(client); }
public void ChangeAchievement(AccountDTO account_dto) { if (account_dto == null) throw new ArgumentNullException("account_dto"); AccountRepository accountRepository = new AccountRepository(); var account = accountRepository.Get(account_dto.Id); if (account != null) { var achievement = new Achievement(account); achievement.ACEENumber = account_dto.ACEENumber; achievement.Score = account_dto.Score; achievement.SpecialityType = account_dto.SpecialityType; achievement.Province = account_dto.Zone.Province; achievement.City=account_dto.Zone.City; accountService.ChangeAchievement(account, achievement); accountRepository.Commit(); } }
public HttpResponseMessage Register([FromBody]RegistrationAccountModel model) { return SafeAction(() => { if (!model.Password.Equals(model.Confirm, StringComparison.InvariantCulture)) { throw new InvalidPasswordsException(); } if (!CaptchaProvider.Validate(model.Captcha.Id, model.Captcha.Text)) { throw new InvalidCaptchaCodeException(); } using (var repository = new AccountRepository()) { repository.Register(model.Username, model.Password, model.Email); return Request.CreateResponse(HttpStatusCode.OK, true); } }, model); }
public async Task ReceiveAsync(AuthenticationTokenReceiveContext context) { var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin"); context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin }); string hashedTokenId = Helper.GetHash(context.Token); using (AccountRepository _repo = new AccountRepository(new MyRoomDbContext())) { var refreshToken = await _repo.FindRefreshToken(hashedTokenId); if (refreshToken != null ) { //Get protectedTicket from refreshToken class context.DeserializeTicket(refreshToken.ProtectedTicket); var result = await _repo.RemoveRefreshToken(hashedTokenId); } } }
public async Task<bool> Login([FromBody] User loginUser) { var accountBus = new AccountRepository(context); var user = await accountBus.AuthenticateAndLoadUser(loginUser.Username, loginUser.Password); if (user == null) throw new ApiException("Invalid Login Credential", 401); var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(ClaimTypes.Name, user.Username)) ; if (user.Fullname == null) user.Fullname = string.Empty; identity.AddClaim(new Claim("FullName", user.Fullname)); await HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); return true; }
public void Initialize(string filename) { IDatabaseFactory databaseFactory = new DatabaseFactory(); IUnitOfWork unitOfWork = new UnitOfWork(databaseFactory); IAccountRepository accountRepository = new AccountRepository(databaseFactory); ITransactionRepository transactionRepository = new TransactionRepository(databaseFactory); ICategoryRepository categoryRepository = new CategoryRepository(databaseFactory); IVendorRepository vendorRepository = new VendorRepository(databaseFactory); ICategoryGroupRepository categoryGroupRepository = new CategoryGroupRepository(databaseFactory); IBillRepository billRepository = new BillRepository(databaseFactory); IBillTransactionRepository billTransactionRepository = new BillTransactionRepository(databaseFactory); IBillGroupRepository billGroupRepository = new BillGroupRepository(databaseFactory); IBudgetCategoryRepository budgetCategoryRepository = new BudgetCategoryRepository(databaseFactory); IAccountGroupRepository accountGroupRepository = new AccountGroupRepository(databaseFactory); IImportDescriptionVendorMapRepository importDescriptionVendorMapRepository = new ImportDescriptionVendorMapRepository(databaseFactory); IAccountService accountService = new AccountService(unitOfWork, accountRepository, transactionRepository, categoryRepository, vendorRepository, billRepository, billTransactionRepository, billGroupRepository, categoryGroupRepository, budgetCategoryRepository, importDescriptionVendorMapRepository); TransactionImporter importer = new TransactionImporter(unitOfWork, accountService, accountRepository, transactionRepository, vendorRepository, categoryGroupRepository, accountGroupRepository, importDescriptionVendorMapRepository); importer.Import(filename); }
public ActionResult Index() { var sr = new SecurityRepository(); var opStatus = sr.InsertSecurityData(); if (opStatus.Status) { var mr = new MarketsAndNewsRepository(); opStatus = mr.InsertMarketData(); if (opStatus.Status) { var ar = new AccountRepository(); opStatus = ar.RefreshAccountsData(); } } ViewBag.OperationStatus = opStatus; return View(); }
public void ChangePassword(Guid accountId, string oldPassword, string newPassword) { if (string.IsNullOrEmpty(oldPassword)) throw new ArgumentNullException("oldPassword"); if (string.IsNullOrEmpty(newPassword)) throw new ArgumentNullException("newPassword"); AccountRepository accountRepository = new AccountRepository(); var account = accountRepository.Get(accountId); if (account != null && DataCryptography.DecryptString(account.Password) == oldPassword) { account.ChangePassword(newPassword); accountRepository.Commit(); // send change password tips email SendMail(account, HostSendMail.EmailCategory.ChangePassword); } else { // throw custermized exception throw new AccountException(Resource.ResourceMessage.ex_AccountIsNotExist); } }
public void SetUp() { _repo = new AccountRepository(new EMARTDBContext()); }
public AccountsService(AccountRepository repository) { _repository = repository; }
public AccountService(BancoVVBAContext context, IConfiguration configuration) { _accountRespository = new AccountRepository(context, configuration); _userRepository = new UserRepository(context, configuration); }
public StudentAccountService() { _accountRepository = new AccountRepository(); }
public ICollection <Account> GetAccountsForUser(int userId) { var repository = new AccountRepository(); return(repository.GetAccountsForUser(userId)); }
public void ProcessMsgAuth(Client pClient, byte[] pMsg) { if (pClient != null && pClient.Packet != null) // check if it's alright { byte[] pPacket = pClient.Packet; var pType = (PacketType)BitConverter.ToInt16(pPacket, 2); if (BitConverter.ToUInt16(pPacket, 0) == 276 && (pType == PacketType.MSG_ACCOUNT1)) { var pRequest = new MsgAccount(pPacket, pClient.IpAddress.GetHashCode()); // tells the console that the user x is trying to login on server y ServerKernel.Log.SaveLog(string.Format("User [{0}] is trying to login on server [{1}].", pClient.Account, pRequest.Server), false, "Login_Server"); // let's check if user is spamming login requests LoginAttemptRecord pLogin = null; if (!ServerKernel.LoginAttemptRecords.TryGetValue(pClient.IpAddress, out pLogin)) { pLogin = new LoginAttemptRecord(pClient.IpAddress); ServerKernel.LoginAttemptRecords.TryAdd(pLogin.IpAddress, pLogin); } if (!pLogin.Enabled) // user spamming login? { pClient.Send(new MsgConnectEx(RejectionType.MAXIMUM_LOGIN_ATTEMPTS)); ServerKernel.Log.SaveLog( string.Format("User [{0}] has passport denied due to exceeding login limit on IP [{1}].", pRequest.Account, pClient.IpAddress), true, "Login_Server"); pClient.Disconnect(); return; } DbAccount pUser = new AccountRepository().SearchByName(pRequest.Account); // fetch user information if (pUser != null) // user exists? { // yes pClient.Account = pUser; // check uncommon characters var szPw = string.Empty; foreach (var c in pRequest.Password) { switch (c) { case '-': szPw += '0'; break; case '#': szPw += '1'; break; case '(': szPw += '2'; break; case '"': szPw += '3'; break; case '%': szPw += '4'; break; case '\f': szPw += '5'; break; case '\'': szPw += '6'; break; case '$': szPw += '7'; break; case '&': szPw += '8'; break; case '!': szPw += '9'; break; default: szPw += c; break; } } //bool bSuccess = true; // check if user has input the right password if (pUser.Password != WhirlpoolHash.Hash(szPw)) { // invalid pw pClient.Send(new MsgConnectEx(RejectionType.INVALID_PASSWORD)); ServerKernel.Log.SaveLog( string.Format("User [{0}] entered an invalid password [{1}].", pUser.Username, pClient.IpAddress), true, "LoginServer"); pClient.Disconnect(); return; } if (pUser.Lock > 0) // user is banned? { if (pUser.Lock >= 3 || pUser.LockExpire == 0 || UnixTimestamp.Timestamp() < pUser.LockExpire) { // banned pClient.Send(new MsgConnectEx(RejectionType.ACCOUNT_BANNED)); ServerKernel.Log.SaveLog( string.Format("User [{0}] has passport denied due to account lock status.", pUser.Username), true, "LoginServer"); pClient.Disconnect(); return; } } //if (pUser.Lock == 2) // user has activated account? //{ // pClient.Send(new MsgConnectEx(RejectionType.ACCOUNT_NOT_ACTIVATED)); // ServerKernel.Log.SaveLog( // string.Format("User [{0}] has passport denied due to account inactive status.", // pUser.Username), true, "LoginServer"); // pClient.Disconnect(); // return; //} // temporary just to leave people join using any server GameServer pServer = ServerKernel.OnlineServers.Values.FirstOrDefault(); if (pServer == null)//!ServerKernel.OnlineServers.TryGetValue(pRequest.Server, out pServer)) // server is not online { pClient.Send(new MsgConnectEx(RejectionType.SERVER_MAINTENANCE)); ServerKernel.Log.SaveLog( string.Format("User [{0}] tried to login on a invalid server [{1}].", pUser.Username, pRequest.Server), true, "LoginServer"); pClient.Disconnect(); return; } uint dwHash = (uint)ThreadSafeRandom.RandGet(1000, int.MaxValue); var pTransferCipher = new TransferCipher(ServerKernel.LoginTransferKey, ServerKernel.LoginTransferSalt, pClient.IpAddress); var pCrypto = pTransferCipher.Encrypt(new[] { pUser.Identity, dwHash }); string szAddress = "135.12.15.139"; // random ip just to connect if (!pServer.IpAddress.StartsWith("127") && pServer.IpAddress != "localhost") { szAddress = pServer.IpAddress; } pServer.Send(new MsgUsrLogin(pUser.Identity, dwHash) { IpAddress = pClient.IpAddress }); pClient.Send(new MsgConnectEx(pCrypto[0], pCrypto[1], szAddress, 5816)); ServerKernel.Log.SaveLog(string.Format("User [{0}] has successfully logged into {1}({2}:{3}).", pUser.Username, pRequest.Server, szAddress, pServer.GamePort), true, "Login_Server", LogType.MESSAGE); pUser.LastLogin = UnixTimestamp.Timestamp(); new AccountRepository().SaveOrUpdate(pUser); return; } else { // no pClient.Send(new MsgConnectEx(RejectionType.INVALID_PASSWORD)); ServerKernel.Log.SaveLog( string.Format("User [{0}] doesn't exist. Connection [{1}].", pRequest.Account, pClient.IpAddress), true, "Login_Server"); } } else { pClient.Send(new MsgConnectEx(RejectionType.INVALID_AUTHENTICATION_PROTOCOL)); ServerKernel.Log.SaveLog(string.Format("User has tried to connect with an invalid protocol at {0}.", pClient.IpAddress)); } pClient.Disconnect(); } }
public IHttpActionResult GetAccountsInEnv(int envId, string AccountName) { AccountRepository repository = new AccountRepository(); return(Ok(repository.GetAccountsInEnv(envId, AccountName))); }
public AccountService(AccountRepository AccountRepository, UserManager <Account> userManager, RoleManager <AppRole> roleManager) { this.repository = AccountRepository; _userManager = userManager; _roleManager = roleManager; }
public NoS0575Processor(ILogger logger, AccountRepository accountRepository, ServerService serverService) { this.logger = logger; this.accountRepository = accountRepository; this.serverService = serverService; }
public void SetUp() { _repo = new AccountRepository(new AccountService.Models.OMDSPDBContext()); }
public OctopusRepository(IOctopusClient client, RepositoryScope repositoryScope = null) { Client = client; Scope = repositoryScope ?? RepositoryScope.Unspecified(); Accounts = new AccountRepository(this); ActionTemplates = new ActionTemplateRepository(this); Artifacts = new ArtifactRepository(this); Backups = new BackupRepository(this); BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(this); CertificateConfiguration = new CertificateConfigurationRepository(this); Certificates = new CertificateRepository(this); Channels = new ChannelRepository(this); CommunityActionTemplates = new CommunityActionTemplateRepository(this); Configuration = new ConfigurationRepository(this); DashboardConfigurations = new DashboardConfigurationRepository(this); Dashboards = new DashboardRepository(this); Defects = new DefectsRepository(this); DeploymentProcesses = new DeploymentProcessRepository(this); Deployments = new DeploymentRepository(this); Environments = new EnvironmentRepository(this); Events = new EventRepository(this); FeaturesConfiguration = new FeaturesConfigurationRepository(this); Feeds = new FeedRepository(this); Interruptions = new InterruptionRepository(this); LibraryVariableSets = new LibraryVariableSetRepository(this); Lifecycles = new LifecyclesRepository(this); Licenses = new LicensesRepository(this); MachinePolicies = new MachinePolicyRepository(this); MachineRoles = new MachineRoleRepository(this); Machines = new MachineRepository(this); Migrations = new MigrationRepository(this); OctopusServerNodes = new OctopusServerNodeRepository(this); PerformanceConfiguration = new PerformanceConfigurationRepository(this); PackageMetadataRepository = new PackageMetadataRepository(this); ProjectGroups = new ProjectGroupRepository(this); Projects = new ProjectRepository(this); ProjectTriggers = new ProjectTriggerRepository(this); Proxies = new ProxyRepository(this); Releases = new ReleaseRepository(this); RetentionPolicies = new RetentionPolicyRepository(this); Schedulers = new SchedulerRepository(this); ServerStatus = new ServerStatusRepository(this); Spaces = new SpaceRepository(this); Subscriptions = new SubscriptionRepository(this); TagSets = new TagSetRepository(this); Tasks = new TaskRepository(this); Teams = new TeamsRepository(this); Tenants = new TenantRepository(this); TenantVariables = new TenantVariablesRepository(this); UserRoles = new UserRolesRepository(this); Users = new UserRepository(this); VariableSets = new VariableSetRepository(this); Workers = new WorkerRepository(this); WorkerPools = new WorkerPoolRepository(this); ScopedUserRoles = new ScopedUserRoleRepository(this); UserPermissions = new UserPermissionsRepository(this); UserTeams = new UserTeamsRepository(this); UserInvites = new UserInvitesRepository(this); loadRootResource = new Lazy <RootResource>(LoadRootDocumentInner, true); loadSpaceRootResource = new Lazy <SpaceRootResource>(LoadSpaceRootDocumentInner, true); }
// // GET: /AccountOverview/ public ActionResult Index() { ViewData["Accounts"] = new AccountRepository().Accounts; return(View()); }
public UserHub() { _userRepository = new UserRepository(); _messageRepository = new MessageRepository(); _accountRepository = new AccountRepository(); }
public ApplicationService(AccountRepository accountRepository, BillingRepository billingRepository) { _accountRepository = accountRepository; _billingRepository = billingRepository; }
public void Setup() { _ctx.Database.Delete(); _repository = new AccountRepository(_ctx); }
public AccountService(AccountRepository repo) { _repo = repo; }
public FileService() { _accountRepository = new AccountRepository("accounts"); _cryptService = new CryptService(); }
public HomeController(AccountRepository repository, IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor) { this.Repository = repository; this.loginFn = new loginFunction(repository); }
public ActionResult CheckListCompleted() { try { AuthenticatedUser _authUser; AccountCheckListInfo _accountCheckList; var _employeeRegInfo = new EmployeeRegistrationInfo(); using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } if (_authUser.IsCheckListCompleted == true) { return(RedirectToAction("Logout", "Auth", new { area = "" })); } using (AccountCheckListRepository Repo = new AccountCheckListRepository()) { _accountCheckList = Repo.GetAccountCheckListByUserId(CurrentUser.AccountId); } if (_accountCheckList.IsPictureUploaded == false) { return(RedirectToAction("UploadPicture", "File")); } using (EmployeeRepository Repo = new EmployeeRepository()) { _employeeRegInfo = Repo.GetRegisterEmployeeInfoById(CurrentUser.EmployeeInfoId); _employeeRegInfo.DateOfJoin = DateTime.Now; Repo.RegisterEmployee(_employeeRegInfo); } using (AccountRepository Repo = new AccountRepository()) { Repo.CheckListCompleted(CurrentUser.AccountId); } using (AuthRepository Repo = new AuthRepository()) { _authUser = Repo.GetAuthenticatedUserById(CurrentUser.EmployeeInfoId); } var _authManager = HttpContext.GetOwinContext().Authentication; var _identity = new ClaimsIdentity(User.Identity); _identity.RemoveClaim(_identity.FindFirst(ClaimTypes.Role)); _identity.AddClaim(new Claim(ClaimTypes.Role, _authUser.Role)); _identity.RemoveClaim(_identity.FindFirst(ClaimTypes.Name)); _identity.AddClaim(new Claim(ClaimTypes.Name, _authUser.FirstName + " " + _authUser.LastName)); //_identity.RemoveClaim(_identity.FindFirst("AccountNo")); //_identity.AddClaim(new Claim("AccountNo", "12345")); _authManager.AuthenticationResponseGrant = new AuthenticationResponseGrant( new ClaimsPrincipal(_identity), new AuthenticationProperties { ExpiresUtc = DateTime.UtcNow.AddMinutes(30), AllowRefresh = true, IsPersistent = false } ); return(RedirectToAction("Dashboard", "Home", new { Area = "Employee" })); } catch (Exception ex) { TempData["Msg"] = AlertMessageProvider.FailureMessage(ex.ToString()); return(View()); } }
private JwtManager() { _accountRepository = new AccountRepository(); }
public AccountBL() { accountRepository = new AccountRepository(); }
private static void Main(string[] args) { var mongoClient = new MongoClient(); mongoClient.DropDatabase("JobOfferDatabase"); var database = mongoClient.GetDatabase("JobOfferDatabase"); var cSharp = new Skill() { Name = "C#" }; var javascript = new Skill() { Name = "Javascript" }; var react = new Skill() { Name = "React" }; var docker = new Skill() { Name = "Docker" }; var java = new Skill() { Name = "Java" }; var skillRepository = new SkillRepository(database); Task.Run(async() => await skillRepository.UpsertAsync(cSharp)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(javascript)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(react)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(docker)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(java)).Wait(); var companyRepository = new CompanyRepository(database); var recruiterRepository = new RecruiterRepository(database); var jobOfferRepository = new JobOfferRepository(database); var personRepository = new PersonRepository(database); var accountRepository = new AccountRepository(database); var recruiterService = new RecruiterService(companyRepository, recruiterRepository, jobOfferRepository, personRepository, accountRepository); var recruiter = new Recruiter(); recruiter.AddClient(new Company("Acme", "Software")); recruiter.IdentityCard = "28.999.999"; recruiter.FirstName = "Patricia"; recruiter.LastName = "Maidana"; recruiter.SetStudy(new Study("UBA", "Lic.RRHH", StudyStatus.Completed)); recruiter.SetPreviousJob(new Job("Coto", "HR Analyst", DateTime.Now.AddYears(-6), true)); recruiter.SetAbility(new Ability(javascript, 9)); var company1 = new Company("Acme", "software"); companyRepository.UpsertAsync(company1).Wait(); recruiterService.CreateRecruiterAsync(recruiter).Wait(); var jobOffer = Task.Run(() => { RecruiterService recruiterService1 = recruiterService; return(recruiterService1.GetNewJobOffer(recruiter.Id)); }).Result; jobOffer.Date = DateTime.Now.Date; jobOffer.Title = "Analista programador"; jobOffer.CompanyId = company1.Id; jobOffer.Zone = "Palermo"; jobOffer.Description = "Para importante empresa ubicada en San Telmo, estamos en búsqueda de desarrollador fullstack con " + "al menos 3 años de experiencia utilizando React y NodeJs.Quien se incorpore estará participando dentro " + "de un proyecto de inteligencia artifical"; jobOffer.AddSkillRequired(new SkillRequired(javascript, 5, true)); jobOffer.AddSkillRequired(new SkillRequired(react, 3)); jobOffer.Language = "Ingles"; jobOffer.LanguageLevel = LanguageLevel.Advance; jobOffer.IsLanguageMandatory = true; jobOffer.ContractInformation = new ContractCondition() { StartingFrom = "Inmediata", KindOfContract = "Relación de dependencia", WorkingDays = "Lunes a viernes 9 a 18" }; recruiterService.SaveJobOfferAsync(jobOffer).Wait(); // var company2 = new Company("KaizenRH", "software"); companyRepository.UpsertAsync(company2).Wait(); var jobOffer2 = Task.Run(() => recruiterService.GetNewJobOffer(recruiter.Id)).Result; jobOffer2.Date = DateTime.Now.Date; jobOffer2.Title = "JAVA Full Stack Developer"; jobOffer2.CompanyId = company2.Id; jobOffer2.Zone = "Las Cañitas"; jobOffer2.Description = "En KaizenRH buscamos Python Developer Junior para trabajar en interesantes proyectos dentro de Startup en expansión LATAM dedicada a la automatización de procesos IT y negocios."; jobOffer2.AddSkillRequired(new SkillRequired(javascript, 5, true)); jobOffer2.AddSkillRequired(new SkillRequired(react, 3)); jobOffer2.AddSkillRequired(new SkillRequired(java, 6, true)); jobOffer2.Language = "Ingles"; jobOffer2.LanguageLevel = LanguageLevel.Intermediate; jobOffer2.ContractInformation = new ContractCondition() { StartingFrom = "Inmediata", KindOfContract = "Relación de dependencia", WorkingDays = "Lunes a viernes 9 a 18" }; recruiterService.SaveJobOfferAsync(jobOffer2).Wait(); // var company3 = new Company("ADN Recursos Humanos", "Seleccion de personal"); companyRepository.UpsertAsync(company3).Wait(); var jobOffer3 = Task.Run(() => recruiterService.GetNewJobOffer(recruiter.Id)).Result; jobOffer3.Date = DateTime.Now.Date; jobOffer3.Title = "Sr. C# Backend Developer/Engineer"; jobOffer3.CompanyId = company3.Id; jobOffer3.Zone = "Microcentro"; jobOffer3.Description = "ADN - Recursos Humanos estamos en la búsqueda de un Sr. Python Backend Developer/Engineer, para Importante Empresa de Tecnología"; jobOffer3.AddSkillRequired(new SkillRequired(cSharp, 5)); jobOffer3.AddSkillRequired(new SkillRequired(javascript, 2, true)); jobOffer3.ContractInformation = new ContractCondition() { StartingFrom = "Inmediata", KindOfContract = "Relación de dependencia", WorkingDays = "Lunes a viernes 9 a 18" }; recruiterService.SaveJobOfferAsync(jobOffer3).Wait(); recruiterService.PublishJobOffer(jobOffer2).Wait(); recruiterService.PublishJobOffer(jobOffer3).Wait(); recruiterService.FinishJobOffer(jobOffer3).Wait(); var pRepo = new RecruiterRepository(database); var aRepo = new AccountRepository(database); var person = pRepo.GetByIdentityCardAsync("28.999.999").Result; var account = new Account() { Id = Guid.NewGuid().ToString(), PersonId = person.Id, Email = "*****@*****.**", Password = "******", IsRecruiter = true }; aRepo.UpsertAsync(account).Wait(); Console.WriteLine("Agregado correctamente!"); Console.ReadKey(); }
public void TestDeleteAccountActionExecute_WithListeners() { using (var testDbInfo = SetupUtil.CreateTestDb()) { //Arrange Mock <ILog> mockLog = new Mock <ILog>(); AccountRepository repo = new AccountRepository(testDbInfo.ConnectionString, mockLog.Object); AccountStateRepository accountStateRepo = new AccountStateRepository(testDbInfo.ConnectionString, mockLog.Object); RepositoryBag repositories = SetupUtil.CreateMockRepositoryBag(testDbInfo.ConnectionString, mockLog.Object, repo, accountStateRepo); AccountDto accountDto = new AccountDto() { AccountKind = Data.Enums.AccountKind.Sink, CategoryId = null, Description = "test account", Name = "Test Account", Priority = 5 }; bool isInsertSuccessful = repo.Upsert(accountDto); long accountId = accountDto.Id.Value; int accountCountBeforeDelete = repo.GetAll().Count(); AccountStateDto stateDto = new AccountStateDto() { AccountId = accountId, Funds = 0, Timestamp = DateTime.Now, IsClosed = false }; isInsertSuccessful &= accountStateRepo.Upsert(stateDto); int stateCountBeforeDelete = accountStateRepo.GetAll().Count(); DeleteAccountCommand action = new DeleteAccountCommand("rm account \"Test Account\"", repositories); action.AccountName.SetData("Test Account"); action.IsRecursiveOption.SetData(false); Mock <ICommandActionListener> mockListener = new Mock <ICommandActionListener>(); mockListener.Setup(x => x.OnCommand(It.Is <DeleteCommandResult <Account> >(a => a.IsSuccessful && a.DeletedItems.Count() == 1 && a.DeletedItems.First().Name.Equals("Test Account")))).Verifiable(); List <ICommandActionListener> listeners = new List <ICommandActionListener>(); listeners.Add(mockListener.Object); //Act bool successful = action.TryExecute(mockLog.Object, listeners); int accountCountAfterDelete = repo.GetAll().Count(); int stateCountAfterDelete = accountStateRepo.GetAll().Count(); bool isClosed = accountStateRepo.GetLatestByAccountId(accountId).IsClosed; //Assert Assert.True(isInsertSuccessful); Assert.True(successful); Assert.Equal(1, accountCountBeforeDelete); Assert.Equal(1, accountCountAfterDelete); Assert.Equal(1, stateCountBeforeDelete); Assert.Equal(2, stateCountAfterDelete); Assert.True(isClosed); mockListener.VerifyAll(); } }
public PersonService(PersonRepository personRepository, JobOfferRepository jobOfferRepository, AccountRepository accountRepository) { _personRepository = personRepository; _jobOffersRepository = jobOfferRepository; _accountRepository = accountRepository; }
public AuthController(CyclepathDbContext context, IConfiguration configuration) { _context = new AccountRepository(context, configuration); _themesContext = new ThemesRepository(context, configuration); _languageContext = new LanguageRepository(context, configuration); }
/// <summary> /// Create provider via repository /// </summary> /// <param name="repository"></param> /// <param name="logger"></param> public AccountIdentityProvider(AccountRepository repository, ILogger logger) { this.logger = logger; AccountRepository = repository; passwordSalter = new SaltManager(); }
public RoomController() { accountRepository = new AccountRepository(ConfigurationManager.ConnectionStrings["defaultConnection"].ToString()); }
public BudgieUserController() { userRepo = new BudgieUserRepository(budgieDBCFModel); accountRepo = new AccountRepository(budgieDBCFModel); buLogic = new BudgieUserLogic(userRepo, accountRepo); }
public async Task GetMonthlyReportForAccount_TestAsync() { var id = new Guid("17b33123-99ea-4bac-b1d1-c3fc0b7579c3"); var options = new DbContextOptionsBuilder <SqlDBContext>() .UseInMemoryDatabase(databaseName: "Test") .Options; using (var context = new SqlDBContext(options)) { context.Accounts.Add(new Account { ResourceId = new Guid("17b33123-99ea-4bac-b1d1-c3fc0b7579c3"), Product = new Product { Id = new Guid(), Name = "some product" }, IBAN = "32141sadf", Name = "Jon", Transactions = new List <Transaction>() { new Transaction { Amount = 20.0M, CategoryId = Models.Enums.Category.Travel, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 1 }, new Transaction { Amount = 120.0M, CategoryId = Models.Enums.Category.Travel, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 4 }, new Transaction { Amount = 40.0M, CategoryId = Models.Enums.Category.Food, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 2 }, new Transaction { Amount = 160.0M, CategoryId = Models.Enums.Category.Food, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 5 } }, Currency = Models.Enums.Currency.RON }); context.Accounts.Add(new Account { ResourceId = new Guid("e2287c78-0454-402a-86bd-b9e6f5cb73be"), Product = new Product { Id = new Guid(), Name = "some product" }, IBAN = "32141sadf", Name = "Jon", Transactions = new List <Transaction>() { new Transaction { Amount = 20.0M, CategoryId = Models.Enums.Category.MedicalExpenses, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 10, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 15 }, new Transaction { Amount = 120.0M, CategoryId = Models.Enums.Category.MedicalExpenses, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 42 }, new Transaction { Amount = 40.0M, CategoryId = Models.Enums.Category.Food, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 45 }, new Transaction { Amount = 55.0M, CategoryId = Models.Enums.Category.Entertainment, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 46 } }, Currency = Models.Enums.Currency.EUR }); context.Accounts.Add(new Account { ResourceId = new Guid("e2417c78-4254-402a-86bd-b9d1f5cb73be"), Product = new Product { Id = new Guid(), Name = "some product" }, IBAN = "32141sadf", Name = "Joffen", Transactions = new List <Transaction>() { new Transaction { Amount = 220.0M, CategoryId = Models.Enums.Category.Clothing, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 113 }, new Transaction { Amount = 420.0M, CategoryId = Models.Enums.Category.Clothing, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 415 }, new Transaction { Amount = 20.0M, CategoryId = Models.Enums.Category.Food, IBAN = "dsafdsafafdas", TransactionDate = new DateTimeOffset(2020, 9, 10, 13, 0, 0, TimeSpan.Zero), TransactionId = 462 } }, Currency = Models.Enums.Currency.GBP }); context.SaveChanges(); } var repo = new AccountRepository(new SqlDBContext(options)); var result = await repo.GetMonthlyReportForAccount(id); var travel = result.Where(x => x.CategoryName == ChallengeING.Models.Enums.Category.Travel.ToString()).Select(y => y.TotalAmount); var food = result.Where(x => x.CategoryName == ChallengeING.Models.Enums.Category.Travel.ToString()).Select(y => y.TotalAmount); Assert.AreEqual(160.0M, travel.FirstOrDefault()); Assert.AreEqual(200.0M, food.FirstOrDefault()); }
public AccountBusiness(IUnitOfWork _unitOfWork) { unitOfWork = _unitOfWork; accountRepository = new AccountRepository(unitOfWork); }