// -------------------------------------------------------------------- Get

        public GroupEntity GetGroup(string userName, string groupSlug, GroupType groupType)
        {
            using (var db = new CollectionDbContext())
            {
                // return all contacts across all groups since groupSlug is empty
                if (groupSlug.IsNullOrEmpty())
                {
                    // TODO paging
                    // get all items across all groups
                    var itemEnts = (from g in db.GroupEntities
                                from i in g.ItemEntities
                                where g.UserName.Equals(userName, StringComparison.InvariantCultureIgnoreCase) &&
                                      g.Id == i.GroupId &&
                                      g.GroupType == groupType
                                select i ).ToList();
                    if (itemEnts == null) return null;

                    var groupEnt = new GroupEntity();
                    foreach (var item in itemEnts)
                    {
                        if (!groupEnt.ItemEntities.Any(i=>i.ItemId == item.ItemId)) // filter out existing for "all" group
                            groupEnt.ItemEntities.Add(item);
                    }
                    groupEnt.UserName = userName;
                    return groupEnt;
                }

                // return contacts for a specific group
                return db.GroupEntities.Include(g => g.ItemEntities)
                                    .FirstOrDefault(g => g.UserName.Equals(userName, StringComparison.InvariantCultureIgnoreCase)
                                        && g.Slug.Equals(groupSlug, StringComparison.InvariantCultureIgnoreCase)
                                        && g.GroupType == groupType);
            }
        }
        // -------------------------------------------------------------------- Create/Update/Delete

        public int CreateGroup(GroupEntity groupEnt)
        {
            using (var db = new CollectionDbContext())
            {
                db.GroupEntities.Add(groupEnt);
                db.SaveChanges();
                return groupEnt.Id;
            }
        }