/// <summary>
        ///  Updates a user's first name, last name, and active flag.
        /// </summary>
        /// <param name="accountInfo"> The account info. </param>
        /// <returns> The <see cref="bool"/>. </returns>
        public bool UpdateUser(AccountAdminViewModel accountInfo)
        {
            var databaseUser = this.userConversions.ConvertAccountViewModelToUser(accountInfo);

            databaseUser.UserRoles    = null;
            databaseUser.CredentialID = 0;
            return(this.userRepo.UpdateUser(databaseUser));
        }
 public ActionResult Edit(AccountAdminViewModel accountadminvm)
 {
     try
     {
         var result = userAccounts.UpdateUser(accountadminvm);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
예제 #3
0
        public AccountAdminViewModel InitializeAdminModel(AccountAdminViewModel model)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("DECLARE @user INT, @facilty INT, @region INT, @agency INT; SELECT @user=COUNT(*) FROM Login; SELECT @facilty=COUNT(*) FROM Facilities WHERE fc_void=0; SELECT @region=COUNT(*) FROM Regions; SELECT @agency=COUNT(*) FROM Agency; SELECT @user usr, @facilty fc, @region rg, @agency ag");

            if (dr.Read())
            {
                model.Users      = Convert.ToInt32(dr[0]);
                model.Facilities = Convert.ToInt32(dr[1]);
                model.Regions    = Convert.ToInt32(dr[2]);
                model.Agencies   = Convert.ToInt32(dr[3]);
            }

            return(model);
        }
예제 #4
0
        private async Task <IEnumerable <AccountAdminViewModel> > PrepopulateAccountsWithUserName(BPMainContext context, ApplicationUserManager manager)
        {
            var list = await context.Accounts.ToListAsync();

            var returnList = new List <AccountAdminViewModel>();
            var userList   = await manager.Users.ToListAsync();

            foreach (var account in list)
            {
                var accountAdminViewModel = new AccountAdminViewModel();
                var verifiedString        = "";
                accountAdminViewModel.ID = account.ID;
                if (account.LoginAttribute != null)
                {
                    var loginId = account.LoginAttribute.LoginIds.FirstOrDefault(x => x.LoginIdType.Index == 4);
                    if (loginId != null)
                    {
                        // we're all set for this account
                        var user = userList.FirstOrDefault(x => x.Id.Equals(loginId.UserId));
                        if (user != null)
                        {
                            verifiedString = user.EmailConfirmed ? $"<p style=\"color: green\">{user.Email} verified</p>" :
                                             $"<p style=\"color: red;\">{user.Email}</p>";
                            accountAdminViewModel.UserName     = user.UserName;
                            accountAdminViewModel.EmailAddress = verifiedString;
                            accountAdminViewModel.AccountName  = user.UserName;
                        }
                    }
                }
                if (account.BusinessAttribute != null)
                {
                    accountAdminViewModel.AccountType = "Business";
                    accountAdminViewModel.AccountName = account.BusinessAttribute.BusinessName;
                }
                else if (account.UserAttribute != null)
                {
                    accountAdminViewModel.AccountType = "Personal";
                }
                else
                {
                    accountAdminViewModel.AccountType = "UnOwned";
                }
                accountAdminViewModel.Created = account?.EntityAttribute?.AccountDates.FirstOrDefault(x => x.AccountDateType.Index == 1).DateLine ?? DateTime.Now;
                returnList.Add(accountAdminViewModel);
            }
            return(returnList);
        }
예제 #5
0
        public ActionResult Index(string search = "")
        {
            var model = new AccountAdminViewModel();

            if (!string.IsNullOrWhiteSpace(search))
            {
                model.Users  = SortUsers(_userManager.FindUsers(search));
                model.Filter = "all";
            }
            else
            {
                model.Users  = SortUsers(_userManager.GetAllUsers());
                model.Filter = "SIP";
            }

            return(View(model));
        }
예제 #6
0
        public void TestInitialize()
        {
            this.conversions = new UserConversions();

            this.createAccountViewModel = new CreateAccountViewModel
            {
                Id              = 1,
                Password        = "******",
                ConfirmPassword = "******",
                FirstName       = "First",
                LastName        = "Last",
                UserName        = "******",
                UserType        = UserRoleType.Admin
            };

            this.user = new User
            {
                ID             = 1,
                Contact        = new Contact(),
                FirstName      = "First",
                LastName       = "Last",
                UserCredential = new UserCredential {
                    ID = 123, PasswordHash = "a298rasdfjkhn", UserName = "******", ResetToken = Guid.NewGuid().ToString()
                },
                UserRoles = new List <UserRole> {
                    new UserRole {
                        RoleTypeID = 1, UserID = 1
                    }
                },
                ServiceProviderID = null,
                IsActive          = true
            };

            this.accountAdminViewModel = new AccountAdminViewModel
            {
                UserId       = 1,
                Email        = "*****@*****.**",
                FirstName    = "First",
                LastName     = "Last",
                IsActive     = true,
                ProviderId   = null,
                ProviderName = string.Empty,
                Role         = UserRoleType.Admin
            };
        }
        /// <summary>
        /// The convert account view model to user.
        /// </summary>
        /// <param name="viewModel"> The view model. </param>
        /// <returns> The <see cref="User"/>. </returns>
        public User ConvertAccountViewModelToUser(AccountAdminViewModel viewModel)
        {
            var convertedUser = new User
            {
                ID                = viewModel.UserId,
                FirstName         = viewModel.FirstName,
                LastName          = viewModel.LastName,
                ServiceProviderID = viewModel.ProviderId,
                UserRoles         = new List <UserRole> {
                    new UserRole {
                        RoleTypeID = (int)viewModel.Role
                    }
                },
                IsActive = viewModel.IsActive
            };

            return(convertedUser);
        }
        /// <summary>
        /// Convert user to account view model.
        /// </summary>
        /// <param name="userToConvert"> The user to convert. </param>
        /// <returns> The <see cref="AccountAdminViewModel"/>. </returns>
        public AccountAdminViewModel ConvertUserToAccountViewModel(User userToConvert)
        {
            var account = new AccountAdminViewModel
            {
                UserId     = userToConvert.ID,
                Email      = userToConvert.UserCredential.UserName,
                FirstName  = userToConvert.FirstName,
                LastName   = userToConvert.LastName,
                ProviderId = userToConvert.ServiceProviderID,
                Role       = (UserRoleType)userToConvert.UserRoles.ToList().First().RoleTypeID,
                IsActive   = userToConvert.IsActive
            };

            if (account.ProviderId != null)
            {
                account.ProviderName = userToConvert.ServiceProvider.ProviderName;
            }

            return(account);
        }
 public IActionResult Admin(AccountAdminViewModel model)
 {
     return(View(model));
 }
예제 #10
0
        public void TestInitialize()
        {
            this.logics = new AccountLogics();
            this.guid   = Guid.NewGuid().ToString();

            this.sampleDatabaseUser = new User
            {
                ID      = 123,
                Contact = new Contact {
                    Phone = "555-555-5555"
                },
                UserCredential = new UserCredential {
                    ID = 4, PasswordHash = "asdfasdf asfasf", UserName = "******"
                },
                FirstName = "First",
                LastName  = "Last",
                UserRoles = new List <UserRole> {
                    new UserRole {
                        RoleTypeID = 1, UserID = 123
                    }
                },
                ServiceProviderID = 2
            };

            this.loginViewModel = new LoginViewModel
            {
                UserId   = 123,
                Email    = "*****@*****.**",
                Password = "******"
            };

            this.createAccountViewModel = new CreateAccountViewModel
            {
                Id              = 0,
                Password        = "******",
                ConfirmPassword = "******",
                FirstName       = "First",
                LastName        = "Last",
                UserName        = "******",
                UserType        = UserRoleType.Admin
            };

            this.accountAdminViewModel = new AccountAdminViewModel
            {
                Email        = "*****@*****.**",
                FirstName    = "First",
                LastName     = "Last",
                ProviderId   = 2,
                ProviderName = "Test Provider",
                Role         = UserRoleType.Provider,
                UserId       = 123
            };


            this.sampleResetPasswordModel = new ResetPasswordViewModel
            {
                UserId   = this.sampleDatabaseUser.ID,
                Password = "******",
                Email    = this.sampleDatabaseUser.UserCredential.UserName,
                Token    = this.guid
            };
        }