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));
        }