コード例 #1
0
ファイル: UserService.cs プロジェクト: lob94/Mad
        public UserGroupDto FindGroupById(long groupId)
        {
            UserGroup    group    = GroupDao.Find(groupId);
            UserGroupDto groupDto = new UserGroupDto(group);

            return(groupDto);
        }
コード例 #2
0
ファイル: UserService.cs プロジェクト: lob94/Mad
        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);
        }
コード例 #3
0
ファイル: UserService.cs プロジェクト: lob94/Mad
        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);
        }
コード例 #4
0
ファイル: UserService.cs プロジェクト: lob94/Mad
        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();
            }
        }