Example #1
0
        public List <DTORecommendation> ShowGroupRecommendations(long groupId)
        {
            GroupUsers group = new GroupUsers();
            string     eventName;

            try { group = GroupUsersDao.Find(groupId); }
            catch (InstanceNotFoundException)
            {
                throw new GroupNotFoundException(groupId);
            }
            List <DTORecommendation> dtoRecommendations = new List <DTORecommendation>();

            try
            {
                List <Recommendation> recomendations = RecommendationDao.FindRecommendationsByGroupId(groupId);

                foreach (var recommedation in recomendations)
                {
                    try { eventName = recommedation.SportEvent.ev_name; }
                    catch (InstanceNotFoundException)
                    {
                        throw new SportEventNotFoundException(groupId);
                    }
                    UserProfile user = UsersProfileDao.Find(recommedation.userId);
                    dtoRecommendations.Add(new DTORecommendation(recommedation.recommendationId, eventName, user.loginName,
                                                                 recommedation.eventId, recommedation.recommendation_text));
                }
            }
            catch (InstanceNotFoundException)
            {
                throw new GroupNotFoundException(groupId);
            }
            return(dtoRecommendations);
        }
Example #2
0
        public List <DTOGroups> ShowAllGroups()
        {
            List <GroupUsers> groups = GroupUsersDao.GetAllElements();

            List <DTOGroups> dtoGroups = new List <DTOGroups>();

            foreach (var group in groups)
            {
                UserProfile user = UsersProfileDao.Find(group.gr_owner);
                dtoGroups.Add(new DTOGroups(group.group_usersId, group.gr_name, group.gr_description, group.UsersOnGroup.Count, group.Recommendation.Count));
            }

            return(dtoGroups);
        }
Example #3
0
        public List <DTOGroupsUser> ShowUserGroups(string loginName)
        {
            UserProfile user;

            try { user = UsersProfileDao.FindByLoginName(loginName); }
            catch (InstanceNotFoundException)
            {
                throw new UserNotFoundException(loginName);
            }
            List <GroupUsers>    grupos    = GroupUsersDao.FindGroupUsersByUserId(user.userId);
            List <DTOGroupsUser> dtoGroups = new List <DTOGroupsUser>();

            foreach (var group in grupos)
            {
                UserProfile userOwner = UsersProfileDao.Find(group.gr_owner);
                dtoGroups.Add(new DTOGroupsUser(group.group_usersId, group.gr_name));
            }

            return(dtoGroups);

            //Decolver mejor lista de dtos.
        }