Пример #1
0
 public static List<Studio> GetStudiosForAdminUser(ApplicationUser currentUser)
 {
     var api = GoPlayApi.Instance;
     List<string> roles = currentUser.GetRoles().Select(r => r.RoleName).ToList();
     if (roles.Contains(GoPlayConstantValues.S_ROLE_ADMIN))
         return api.GetAllStudios().Data;
     if (roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ADMIN))
         return api.GetStudios(currentUser.Id).Data;
     return null;
 }
Пример #2
0
        public static Game GetGameForCurrentUser(ApplicationUser currentUser, int game_id)
        {
            var api = GoPlayApi.Instance;
            List<string> roles = currentUser.GetRoles().Select(r => r.RoleName).ToList();
            if (!roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ADMIN) && !roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ACCOUNTANT))
            {
                return api.GetGames(true, false).Data.FirstOrDefault(x => x.id == game_id);
            }

            return api.GetAllGames().Data.FirstOrDefault(x => x.is_archived == false && x.id == game_id);
        }
Пример #3
0
        public static Game GetGameForAdminUser(ApplicationUser currentUser, int game_id)
        {
            var api = GoPlayApi.Instance;
            List<string> roles = currentUser.GetRoles().Select(r => r.RoleName).ToList();
            if (roles.Contains(GoPlayConstantValues.S_ROLE_ADMIN))
                return api.GetGame(game_id).Data;

            return GetGameForCurrentUser(currentUser, game_id);
        }
Пример #4
0
        public static List<Game> GetGamesForAdminUser(ApplicationUser currentUser)
        {
            var api = GoPlayApi.Instance;
            List<string> roles = currentUser.GetRoles().Select(r => r.RoleName).ToList();
            if (roles.Contains(GoPlayConstantValues.S_ROLE_ADMIN))
                return api.GetAllGames().Data.OrderBy(x => x.name).ToList();
            if (roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ADMIN) || roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ACCOUNTANT))
                return api.GetGamesForAdmin(currentUser.Id, false).Data;

            return api.GetAllGames().Data.Where(x => x.is_archived == false && x.is_active == true).OrderBy(x => x.name).ToList();
        }
Пример #5
0
        public static List<Game> getGamesPerPageForCurrentUser(int page, int pagesize, ApplicationUser currentUser, List<Game> games = null, SearchCondition searchConditions = null)
        {
            int fromIndex = (page - 1) * pagesize;
            int toIndex = page * pagesize;

            var api = GoPlayApi.Instance;
            if (games == null)
            {
                games = api.GetGames(searchConditions).Data;
            }

            if (games == null && searchConditions == null)
            {
                if (currentUser != null)
                {
                    List<string> roles = currentUser.GetRoles().Select(r => r.RoleName).ToList();
                    if (!roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ADMIN) && !roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ACCOUNTANT))
                    {
                        return api.GetAllGames().Data.Where(x => x.is_active && x.is_archived == false)
                            .OrderBy(x => x.id)
                            .Skip(fromIndex)
                            .Take(toIndex - fromIndex)
                            .ToList();
                    }
                }
                return api.GetAllGames().Data.Where(x => x.is_archived == false).OrderBy(x => x.id)
                    .Skip(fromIndex)
                    .Take(toIndex - fromIndex)
                    .ToList();
            }
            return games.Skip(fromIndex).Take(toIndex - fromIndex).ToList();
        }
Пример #6
0
        public static List<Game> GetGamesForCurrentUser(ApplicationUser currentUser, SearchCondition searchConditions = null)
        {
            var api = GoPlayApi.Instance;

            var games = api.GetGames(searchConditions);
            if (!games.HasData && searchConditions == null)
            {
                List<string> roles = new List<string>();
                if (currentUser != null)
                {
                    roles = currentUser.GetRoles().Select(r => r.RoleName).ToList();
                }
                if (!roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ADMIN) && !roles.Contains(GoPlayConstantValues.S_ROLE_GAME_ACCOUNTANT))
                {
                    return api.GetAllGames().Data.Where(x => x.is_active && x.is_archived == false).OrderBy(x => x.id).ToList();
                }
                return api.GetAllGames().Data.Where(x => x.is_archived == false).OrderBy(x => x.id).ToList();
            }
            return games.Data;
        }