예제 #1
0
        public async Task <UserGroupsModel> GetUserGroupsAsync(Interfaces.IDataRepo repo, string game, string user)
        {
            var userObj = await repo.GetUser(user);

            if (userObj == null)
            {
                UserGroupsModel empty = new UserGroupsModel
                {
                    UserName = "******"
                };

                return(empty);
            }

            var gameGroups = await repo.GetGroupsAsync(game);

            UserGroupsModel userGroups = new UserGroupsModel {
                UserName = user, Game = game
            };

            userGroups.UserGroups = from g in gameGroups
                                    join ug in userObj.Groups on g.id equals ug
                                    select new GroupNameModel
            {
                Id   = g.id,
                Name = g.Name
            };

            userGroups.OtherGroups = from g in gameGroups.Where(g => !userObj.Groups.Contains(g.id))
                                     select new GroupNameModel
            {
                Id   = g.id,
                Name = g.Name
            };

            return(userGroups);
        }
예제 #2
0
 public async Task <IEnumerable <Models.GroupModel> > GetGameGroupsAsync(Interfaces.IDataRepo repo, string game)
 {
     return(await repo.GetGroupsAsync(game));
 }