Exemplo n.º 1
0
        public UserGroupDto FindGroupById(long groupId)
        {
            UserGroup    group    = GroupDao.Find(groupId);
            UserGroupDto groupDto = new UserGroupDto(group);

            return(groupDto);
        }
Exemplo n.º 2
0
        public ICollection <Recommendation> AddRecommendation(long eventId, ICollection <long> groups, long userId, string description)
        {
            Event e = EventDao.Find(eventId);
            ICollection <Recommendation> recs = new List <Recommendation>();

            foreach (long groupId in groups)
            {
                Recommendation r = RecommendationDao.FindByGroupIdAndEventIdAndUsrId(groupId, userId, eventId);
                if (r != null)
                {
                    r.reason = description;
                    RecommendationDao.Update(r);
                }
                else
                {
                    UserGroup      g   = GroupDao.Find(groupId);
                    UserProfile    u   = UserProfileDao.Find(userId);
                    Recommendation rec = new Recommendation();
                    rec.UserGroup   = g;
                    rec.UserProfile = u;
                    rec.Event       = e;
                    rec.reason      = description;
                    RecommendationDao.Create(rec);
                    recs.Add(rec);
                }
            }
            return(recs);
        }
Exemplo n.º 3
0
        public UserGroup UnJoinGroup(long userId, long groupId)
        {
            UserGroup   group = GroupDao.Find(groupId);
            UserProfile user  = UserProfileDao.Find(userId);

            group.UserProfiles.Remove(user);
            GroupDao.Update(group);
            return(group);
        }
Exemplo n.º 4
0
        public ICollection <RecommendationDto> FindGroupRecommendations(long groupId, long userId, int startIndex, int count)
        {
            UserProfile u = UserProfileDao.Find(userId);
            UserGroup   g = GroupDao.Find(groupId);

            if (g.UserProfiles.Contains(u))
            {
                ICollection <Recommendation>    recs    = RecommendationDao.FindByGroupId(groupId, startIndex, count);
                ICollection <RecommendationDto> recsDto = new List <RecommendationDto>();

                foreach (Recommendation r in recs)
                {
                    Event e = EventDao.Find(r.eventId);
                    recsDto.Add(new RecommendationDto(r, e.name));
                }
                return(recsDto);
            }
            else
            {
                throw new Exception();
            }
        }