Example #1
0
        public async Task<IdentityResult> RegisterUser(User user, string password)
        {
            user.IsActive = true;
            user.UpdatedAt = DateTime.UtcNow;
            user.Id = Guid.NewGuid().ToString();
            var result = await _userManager.CreateAsync(user, password);
            await _userManager.AddToRoleAsync(user.Id, user.AccountType);

            return result;
        }
Example #2
0
 public static List<Account> GetAccounts(User client)
 {
     BankContext bank = new BankContext();
     List<Account> accounts = new List<Account>();
     foreach (var item in bank.Accounts.ToList())
     {
         if (item.ClientId.ToString().Equals(client.Id))
         {
             accounts.Add(item);
         }
     }
     return accounts;
 }
Example #3
0
        public static void CreateAccount(User client, Currency currency)
        {
            BankContext bank = new BankContext();
            Account account = new Account();

            account.ClientId = client.Id;
            account.OpeningDate = DateTime.UtcNow;
            account.Currency = currency;
            account.Amount = 0;

            bank.Accounts.Add(account);
            bank.SaveChanges();
        }
Example #4
0
        public async Task<IdentityResult> CreateAsync(User user)
        {
            var result = await _userManager.CreateAsync(user);

            return result;
        }
Example #5
0
 public IdentityResult UpdateUser(User user)
 {
     user.UpdatedAt = DateTime.UtcNow;
     var result = _userManager.Update(user);
     if (!string.IsNullOrEmpty(user.AccountType) && _userManager.IsInRole(user.Id, user.AccountType))
     {
         _userManager.RemoveFromRoles(user.Id);
         _userManager.AddToRole(user.Id, user.AccountType);
     }
     return result;
 }
 public static AuthenticationProperties CreateProperties(User user)
 {
     IDictionary<string, string> data = new Dictionary<string, string>
     {
         { "user_id", user.Id },
         { "isClient", user.IsRegularUser.ToString() },
         { "firstName", user.FirstName },
         { "lastName", user.LastName },
     };
     return new AuthenticationProperties(data);
 }