public ActionResult List()
        {
            GroupsService groupsService = new GroupsService();
            GroupsListVM  model         = new GroupsListVM();

            TryUpdateModel(model);

            model.Groups = new Dictionary <Group, List <SelectListItem> >();

            foreach (var group in groupsService.GetAll().Where(g => g.UserID == AuthenticationManager.LoggedUser.ID))
            {
                List <SelectListItem> contacts = groupsService.GetSelectedContacts(group).ToList();
                model.Groups.Add(group, contacts);
            }

            if (!String.IsNullOrEmpty(model.Search))
            {
                model.Groups = model.Groups.Where(g => g.Key.Name.ToLower().Contains(model.Search.ToLower())).ToDictionary(v => v.Key, v => v.Value);
            }

            switch (model.SortOrder)
            {
            case "name_desc": model.Groups = model.Groups.OrderByDescending(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break;

            case "name_asc":
            default: model.Groups = model.Groups.OrderBy(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break;
            }

            return(View(model));
        }
        public ActionResult Index()
        {
            GroupsListVM model = new GroupsListVM();

            TryUpdateModel(model);

            GroupRepository groupRepo = new GroupRepository();

            model.Entities = groupRepo.GetAll(g => g.UserID == AuthenticationService.LoggedUser.ID);

            return(View(model));
        }
        public virtual ActionResult List(string term = "", int page = 1, int count = 10,
                                         Order order = Order.Descending, GroupsSearchBy objSearchBy = GroupsSearchBy.Name)
        {
            //#region Retrive Data
            int total;
            var articles = _GroupsService.GetDataTable(out total, term, page, order, objSearchBy, count);
            var model    = new GroupsListVM
            {
                Order       = order,
                PageCount   = count,
                PageNumber  = page,
                GroupsList  = articles,
                Term        = term,
                TotalGroups = total
            };

            ViewBag.CountList = DropDown.GetCountList(count);
            ViewBag.OrderList = DropDown.GetOrderList(order);
            return(PartialView("_ListPartial", model));
        }