/// <summary>
        /// Lampen 5, interesse 3 per, ageGroup 2. schoollevel 2, location 2 filters toepassen
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <IFeed> > GetFeedsAsync(ClaimsPrincipal user)
        {
            IGeneralUser loggedInGeneralUser = await _generalUsersService.FindByIdentityAsync(user);

            IEnumerable <IGeneralUser> feedUsers = await _generalUsersRepository.FindWithSimilarPreferenceAsync(loggedInGeneralUser, 1);

            IEnumerable <ILink> feedLinks = await _linksRepository.FindWithSimilarPreferenceAsync(loggedInGeneralUser, 4);

            List <IFeed> feeds = new List <IFeed>();
            var          MatchedGeneralUser = feedUsers.FirstOrDefault();

            if (MatchedGeneralUser != default)
            {
                ILimitedGeneralUser MatchedGeneralUserResponse = _mapper.Map <ILimitedGeneralUser>(MatchedGeneralUser);
                feeds.Add(new Feed {
                    Type = FeedType.GeneralUser, Body = MatchedGeneralUserResponse
                });
            }

            foreach (ILink link in feedLinks)
            {
                var linkResponse = _mapper.Map <GetLinkResponse>(link);
                feeds.Add(new Feed {
                    Type = FeedType.Link, Body = linkResponse
                });
            }

            return(feeds);
        }
        public async Task <JsonResponse> GetMeAsync()
        {
            try
            {
                IGeneralUser generalUser = await _generalUsersService.FindByIdentityAsync(base.User);

                var response = _mapper.Map <IGeneralUser, GetGeneralUserResponse>(generalUser);

                return(new JsonResponse(response, HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                await _logger.LogErrorAsync(ex.Message, ex);

                return(new JsonResponse(ex.Message, HttpStatusCode.BadRequest));
            }
        }
        public async Task <ILink> CreateLinkAsync(ILink link, ClaimsPrincipal user)
        {
            IGeneralUser generalUser = await _generalUsersService.FindByIdentityAsync(user);

            return(await _linkRepository.CreateLinkForUserAsync(link, generalUser));
        }
Esempio n. 4
0
        public async Task <IEnumerable <IGeneralUser> > GetMyBuddiesAsync(ClaimsPrincipal user)
        {
            IGeneralUser generalUser = await _generalUsersService.FindByIdentityAsync(user);

            return(await _buddiesRepository.GetMatchedBuddiesAsync(generalUser.Id));
        }