Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="kpGUID"></param>
        /// <returns></returns>
        //public Goal GetGoalByTeamId(string kpGUID, int teamId)
        //{
        //    string teamUrl = this.dataAccess.CurrentUser.GetTeamUrl(teamId);
        //    Goal goal = this.dataAccess.GetEntityObject<Goal>(teamUrl, this.ListName, kpGUID);
        //    return goal;
        //}

        public List <Goal> GetGoalsByTeam(int teamId)
        {
            Team team = TeamRepository.GetTeam(teamId);

            //if (this.dataAccess.CurrentUser.Teams.Contains(team))
            return(this.dataAccess.GetEntityObjects <Goal>(team.SiteUrl, this.LIST_NAME));
            //else
            // TODO: make this a type AccessDeniedException
            //     throw new Exception("User does not have access to this team.");
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="teamId"></param>
 /// <returns></returns>
 public static Team GetTeam(int teamId)
 {
     if (TeamRepository.Teams != null)
     {
         return(TeamRepository.Teams.Find(t => t.KPID.Equals(teamId)));
     }
     else
     {
         TeamRepository repo = new TeamRepository(new SPDataAccess());
         repo.Init();
         return(repo.Items.Find(t => t.KPID.Equals(teamId)));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the user account information including
 /// the info from KPConfigList and KPAdmins
 /// TODO: should consider collapsing these lists
 /// into a single account list that includes access control
 /// </summary>
 /// <returns></returns>
 public void GetCurrentUserAccount(KPUser kpUser)
 {
     this.Init();
     // fetch config list to get list of teams
     //if (userCache.ContainsKey(kpUser.Alias) && cacheTimestamp.AddMinutes(30) < new DateTime())
     if (userCache.ContainsKey(kpUser.Alias))
     {
         kpUser = userCache[kpUser.Alias];
     }
     else
     {
         ConfigList     config         = this.Items.Find(c => c.KPUserName == kpUser.Alias);
         TeamRepository teamRepository = new TeamRepository(this.dataAccess);
         List <Team>    teams          = teamRepository.GetAllItems();
         kpUser.PrimaryTeam = teams.Find(t => t.KPID == config.PrimaryTeam);
         kpUser.Teams       = teams.FindAll(t => config.AdditionalTeams.Contains(t.KPID));
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Used by SheetImport to fetch user items for comparison - Add/Update items
        /// This method gets items from the specified Team (Org) and all sub-teams the user has access to
        /// </summary>
        /// <param name="entityName"></param>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public List <KPListItem> GetUserEntities(string entityName, int teamId)
        {
            // initializes lookup lists and creates KPUser context
            if (this.User == null)
            {
                this.SetCurrentUser();
            }

            List <KPListItem> items   = new List <KPListItem>();
            List <int>        teamIds = TeamRepository.GetChildTeamIds(this.User.Teams, teamId);

            teamIds.Add(teamId);
            // get the specified entities for the current user
            foreach (int tid in teamIds)
            {
                items.AddRange(this.spDataAccess.GetKPListItems(tid, entityName));
            }

            return(items);
        }