public ClientCertificatesForUserViewModel(IClientCertificatesRepository clientCertificatesRepository, IUserManagementRepository userManagementRepository, string username)
 {
     this.clientCertificatesRepository = clientCertificatesRepository;
     this.userManagementRepository = userManagementRepository;
     var allnames =
         userManagementRepository.GetUsers()
         .Select(x => new SelectListItem
         {
             Text = x
         }).ToList();
     allnames.Insert(0, new SelectListItem { Text = "-Choose-", Value = "" });
     this.AllUserNames = allnames;
     
     this.UserName = username;
     NewCertificate = new ClientCertificate { UserName = username };
     if (!IsNew)
     {
         var certs =
                 this.clientCertificatesRepository
                 .GetClientCertificatesForUser(this.UserName)
                     .ToArray();
         this.Certificates = certs;
     }
     else
     {
         this.Certificates = new ClientCertificate[0];
     }
 }
        public ClientCertificatesForUserViewModel(IClientCertificatesRepository clientCertificatesRepository, IUserManagementRepository userManagementRepository, string username)
        {
            this.clientCertificatesRepository = clientCertificatesRepository;
            this.userManagementRepository     = userManagementRepository;
            var allnames =
                userManagementRepository.GetUsers()
                .Select(x => new SelectListItem
            {
                Text = x
            }).ToList();

            allnames.Insert(0, new SelectListItem {
                Text = "-Choose-", Value = ""
            });
            this.AllUserNames = allnames;

            this.UserName  = username;
            NewCertificate = new ClientCertificate {
                UserName = username
            };
            if (!IsNew)
            {
                var certs =
                    this.clientCertificatesRepository
                    .GetClientCertificatesForUser(this.UserName)
                    .ToArray();
                this.Certificates = certs;
            }
            else
            {
                this.Certificates = new ClientCertificate[0];
            }
        }
        public UsersViewModel(Repositories.IUserManagementRepository UserManagementRepository, string filter)
        {
            // TODO: Complete member initialization
            this.UserManagementRepository = UserManagementRepository;
            this.Filter = filter;

            if (String.IsNullOrEmpty(filter))
            {
                Users = UserManagementRepository.GetUsers();
                Total = Showing;
            }
            else
            {
                Users = UserManagementRepository.GetUsers(filter);
                Total = UserManagementRepository.GetUsers().Count();
            }
        }
        public UsersViewModel(Repositories.IUserManagementRepository UserManagementRepository, string filter)
        {
            this.UserManagementRepository = UserManagementRepository;
            this.Filter = filter;

            if (String.IsNullOrEmpty(filter))
            {
                Users = UserManagementRepository.GetUsers();
                Total = Showing = Users.Count();
            }
            else
            {
                Users = UserManagementRepository.GetUsers(filter);
                Total = UserManagementRepository.GetUsers().Count();
                Showing = Users.Count();
            }

            UsersDeleteList = Users.Select(x => new UserDeleteModel { Username = x }).ToArray();
        }
        public UsersViewModel(Repositories.IUserManagementRepository UserManagementRepository, string filter)
        {
            this.UserManagementRepository = UserManagementRepository;
            this.Filter = filter;

            if (String.IsNullOrEmpty(filter))
            {
                Users = UserManagementRepository.GetUsers();
                Total = Showing = Users.Count();
            }
            else
            {
                Users   = UserManagementRepository.GetUsers(filter);
                Total   = UserManagementRepository.GetUsers().Count();
                Showing = Users.Count();
            }

            UsersDeleteList = Users.Select(x => new UserDeleteModel {
                Username = x
            }).ToArray();
        }
Exemple #6
0
        private void Init(int currentPage, string filter)
        {
            if (currentPage <= 0)
            {
                CurrentPage = 1;
            }
            else
            {
                CurrentPage = currentPage;
            }

            int rows     = 20;
            int startRow = (currentPage - 1) * rows;

            if (String.IsNullOrEmpty(filter))
            {
                int total;
                Users = UserManagementRepository.GetUsers(startRow, rows, out total);
                Total = total;
            }
            else
            {
                int total;
                Users = UserManagementRepository.GetUsers(filter, startRow, rows, out total);
                Total = total;
            }

            if (Total < rows)
            {
                Showing = Total;
            }
            else
            {
                Showing = rows;
            }
            UsersDeleteList = Users.Select(x => new UserDeleteModel {
                Username = x
            }).ToArray();
        }