Beispiel #1
0
        /// <summary>
        /// Notifications for activities
        ///  - on project I created
        ///  - on projects I follow (except if the project is private)
        ///  - on my friends (except on private projects)
        ///  - on projects i'm invited to
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <Activity> GetActivitiesByUserId(int userId, int count = -1)
        {
            if (ServiceProject == null)
            {
                throw new Exception("you must inject manually the serviceproject when you instanciate the ActivityService. Do something like activityServiceObject.serviceProject = ... ");
            }
            //find my projects
            List <int> projectIds = ServiceProject.GetProjectIds(userId);

            //find the projects I follow which are not private
            projectIds.AddRange(serviceFollow.GetFollowedPublicProjectIds(userId));

            //find the project I got invited (and I accepted)
            projectIds.AddRange(serviceInvit.GetAcceptedInvitsProjectIds(userId));


            //find the people I follow
            //Todo : find the people a user follows

            var result = this.repoActivity.GetNotificationsByProjectIds(projectIds, userId);

            if (count > 0)
            {
                result = result.Take(count);
            }
            return(result.ToList());
        }