Exemple #1
0
        public ActionResult AccountList(int page = 1)
        {
            var ListViewModel = new Models.AccountPagedListViewModel();

            ListViewModel.CurrentPage = page < 1 ? 1 : page;
            ListViewModel.PageSize    = ListViewModel.PageSize < 1 ? pageSize : ListViewModel.PageSize;

            var myAccount    = DB_GEN_Repo.All().OrderBy(o => o.chUserID).ToArray(); // DB_GEN.GenProxyAccount.OrderBy(o => o.chUserID).ToArray();
            var proxyAccount = hluser_Repo.All().OrderBy(o => o.user).ToArray();     // hluser.passwd.OrderBy(o => o.user).ToArray();

            var result = from his in myAccount
                         join mysql in proxyAccount
                         on his.chUserID equals mysql.user
                         select new Models.ProxyAccountViewModel()
            {
                UserID    = his.chUserID,
                UserName  = his.chUserName,
                DeptName  = his.chDeptName,
                dtEndDate = his.dtEndDate,
                NoteID    = his.chEMail,
                isSynced  = his.chXData.ToLower() == mysql.password.ToLower() ? true : false,
                isEnabled = !mysql.enabled
            };

            ListViewModel.Accounts = result.OrderBy(o => o.UserID).ToPagedList(ListViewModel.CurrentPage, ListViewModel.PageSize);
            //ListViewModel.Accounts = DB_GEN_Repo.All().OrderBy(o => o.chUserID).ToPagedList(ListViewModel.CurrentPage, ListViewModel.PageSize);
            ListViewModel.Depts = new SelectList(DB_GEN_Repo.GetDeptListForDropDownList(), "<未選擇>");

            return(View(ListViewModel));
        }
Exemple #2
0
        public ActionResult AccountList(Models.AccountPagedListViewModel model)
        {
            var result = DB_GEN_Repo.All();

            if (!string.IsNullOrWhiteSpace(model.Parameter.ByUserID))
            {
                result = result.Where(w => w.chUserID.Contains(model.Parameter.ByUserID));
            }
            if (!string.IsNullOrWhiteSpace(model.Parameter.ByUserName))
            {
                result = result.Where(w => w.chUserName.Contains(model.Parameter.ByUserName));
            }
            if ((!string.IsNullOrWhiteSpace(model.Parameter.ByDeptName)) && (model.Parameter.ByDeptName != "<未選擇>"))
            {
                result = result.Where(w => w.chDeptName.Contains(model.Parameter.ByDeptName));
            }

            var depts = result.Select(s => s.chDeptName).Distinct().ToList();

            depts.Add("<未選擇>");
            depts.Sort();
            model.Depts = new SelectList(depts, "<未選擇>");

            model.CurrentPage = model.CurrentPage < 1 ? 1 : model.CurrentPage;
            model.PageSize    = model.PageSize < 1 ? pageSize : model.PageSize;

            var proxyAccount = MedProxy_Repo.All().OrderBy(o => o.user).ToArray(); // hluser.passwd.OrderBy(o => o.user).ToArray();
            var vm           = from his in result.ToArray()
                               join mysql in proxyAccount
                               on his.chUserID.Trim() equals mysql.user.Trim()
                               into mysqlJoin
                               from mysql in mysqlJoin.DefaultIfEmpty()
                               select new Models.ProxyAccountViewModel()
            {
                UserID    = his.chUserID,
                UserName  = his.chUserName,
                DeptName  = his.chDeptName,
                dtEndDate = his.dtEndDate,
                NoteID    = his.chEMail,
                isSynced  = mysql == null ? false : his.chXData.ToLower() == mysql.password.ToLower() ? true : false,
                isEnabled = mysql == null ? false : !mysql.enabled
            };

            model.Accounts = vm.OrderBy(o => o.UserID).ToPagedList(model.CurrentPage, model.PageSize);

            return(View(model));
        }