コード例 #1
0
        public ActionResult GetUsers(string fullname, string email, string create_at)
        {
            var users = context.Users.GetAll();

            if (!String.IsNullOrEmpty(fullname) && !fullname.Equals("Все"))
            {
                users = users.Where(u => u.FullName == fullname);
            }

            if (!String.IsNullOrEmpty(email) && !email.Equals("Все"))
            {
                users = users.Where(u => u.Email == email);
            }

            if (!String.IsNullOrEmpty(create_at) && !create_at.Equals("Все"))
            {
                users = users.Where(u => u.Create_At == Convert.ToDateTime(create_at));
            }

            UserFilterViewModel userFilter = new UserFilterViewModel
            {
                Users    = users.ToList(),
                FullName = new SelectList(new List <string>()
                {
                    "Все", "Круковский А.Ю.", "Мурканич А.Ю.", "Паркунович И.Е.", "Миркович А.Т."
                }),
                Email = new SelectList(new List <string>()
                {
                    "Все", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"
                }),
                Create_At = new SelectList(new List <string>()
                {
                    "Все", (new DateTime(2019, 07, 16)).ToString()
                })
            };

            return(View(userFilter));
        }
コード例 #2
0
        public async Task <IndexUserViewModel> GetUsers(UserFilterViewModel indexUser, int page)
        {
            if (indexUser == null)
            {
                return(new IndexUserViewModel()
                {
                    PageViewModel = new PageViewModel(0, 1, 3),
                    UserInfo = new List <UserInfo>(),
                    UserFilterViewModel = indexUser
                });
            }
            indexUser.SearchValue  = indexUser.SearchValue == null ? "Any" : indexUser.SearchValue;
            indexUser.SearchFilter = indexUser.SearchFilter == null ? "" : indexUser.SearchFilter;
            indexUser.SortItem     = indexUser.SortItem == null ? "" : indexUser.SortItem;

            IEnumerable <UserInfo> item = new List <UserInfo>();

            item = GetSortUser(await GetSearchingUser(indexUser), indexUser.SortItem);

            var count     = item.Count();
            var skipCells = item.Skip((page - 1) * 3).Take(3).ToList();

            if (skipCells.Count == 0 && page != 1)
            {
                skipCells = item.Skip((page - 2) * 3).Take(3).ToList();
                page     -= 1;
            }

            PageViewModel      pageViewModel = new PageViewModel(count, page, 3);
            IndexUserViewModel viewModel     = new IndexUserViewModel
            {
                PageViewModel       = pageViewModel,
                UserInfo            = skipCells,
                UserFilterViewModel = indexUser
            };

            return(viewModel);
        }
コード例 #3
0
 public override IExecutionResult <Tuple <List <UserIndexViewModel>, int> > GetAllFiltered(UserFilterViewModel filter)
 {
     Expression <Func <ApplicationUser, bool> > where = i => true;
     if (!string.IsNullOrEmpty(filter.Search))
     {
         if ((filter.SearchInEmail ?? false) &&
             (filter.SearchInUsername ?? false) &&
             (filter.SearchInName ?? false))
         {
             where = i =>
                     i.Email.Contains(filter.Search) ||
                     i.CUsername.Contains(filter.Search) ||
                     i.Name.Contains(filter.Search);
         }
         else if ((filter.SearchInEmail ?? false) && (filter.SearchInUsername ?? false))
         {
             where = i =>
                     i.Email.Contains(filter.Search) ||
                     i.CUsername.Contains(filter.Search);
         }
         else if ((filter.SearchInUsername ?? false) && (filter.SearchInName ?? false))
         {
             where = i => i.CUsername.Contains(filter.Search) ||
                     i.Name.Contains(filter.Search);
         }
         else if ((filter.SearchInEmail ?? false) && (filter.SearchInName ?? false))
         {
             where = i =>
                     i.Email.Contains(filter.Search) ||
                     i.Name.Contains(filter.Search);
         }
         else if (filter.SearchInEmail ?? false)
         {
             where = i => i.Email.Contains(filter.Search);
         }
         else if (filter.SearchInName ?? false)
         {
             where = i => i.Name.Contains(filter.Search);
         }
         else
         {
             where = i => i.CUsername.Contains(filter.Search);
         }
     }
     return(base.getAllFiltered(where : where, filter: filter, order: c => c.Id));
 }
コード例 #4
0
 public ActionResult _PaginationPartial(UserFilterViewModel model)
 {
     return PartialView("_PaginationPartial", model ?? new UserFilterViewModel());
 }