public IActionResult AutoSearch(UserPreferences userPreferences)
        {
            string country         = userPreferences.Country;
            string city            = userPreferences.City;
            string theme           = userPreferences.Theme;
            string technologyAreas = userPreferences.TechArea;
            string alignment       = userPreferences.Alignment;
            int?   rating          = userPreferences.Rank;
            IEnumerable <Record> s = sd.getStart().records;

            Startups.RateStartups(s);
            IEnumerable <Record> found = s.Where(x =>
                                                 (string.IsNullOrWhiteSpace(country) || x.startups.Country.ToLower() == country.ToLower()) &&
                                                 (string.IsNullOrWhiteSpace(city) || x.startups.City == city) &&
                                                 (string.IsNullOrWhiteSpace(theme) || x.startups.Themes != null && x.startups.Themes.Contains(theme)) &&
                                                 (string.IsNullOrWhiteSpace(technologyAreas) || x.startups.TechnologyAreas != null && x.startups.TechnologyAreas.Contains(technologyAreas)) &&
                                                 (string.IsNullOrWhiteSpace(alignment) || x.startups.Alignment != null && x.startups.Alignment.Contains(alignment)) &&
                                                 (rating == null || x.startups.Rating >= rating));

            foreach (Record r in found)
            {
                r.startups.Comments = _context.Comments.Where(x => x.CompanyName == r.startups.CompanyName && x.FavoriteId == null).ToList();
            }
            return(View("Search", found));
        }
        //favorite action method to find list of user's favorites
        public async Task <IActionResult> Favorites()
        {
            string uid = User.FindFirstValue(ClaimTypes.NameIdentifier);

            AspNetUsers thisAspUser = _context.AspNetUsers.Where(x => x.Id == uid).First();

            Users thisUser = _context.Users.Where(x => x.UserId == uid).First();

            ViewBag.AspUser = thisAspUser;

            ViewBag.User = thisUser;

            Startups startups = await _seamedInDal.GetStartups();

            var rankedStartups = Ranking(startups, thisUser).ToList();

            ViewBag.Startups = rankedStartups;

            string id = User.FindFirstValue(ClaimTypes.NameIdentifier);

            List <Favorites> f = _context.Favorites.Where(x => x.UserId == id).ToList();

            List <Record> records = new List <Record>();

            foreach (Favorites favorites in f)
            {
                Record record = await _seamedInDal.GetStartUpById(favorites.ApiId);

                records.Add(record);
            }

            return(View(records));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Poster,Texts,Country,AboutProject")] Startups startups)
        {
            if (id != startups.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(startups);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StartupsExists(startups.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(startups));
        }
Example #4
0
        public async Task <IActionResult> SearchResultsGlobal(List <string> source, List <string> scout, List <string> alignment, List <string> theme, List <string> technologyArea, List <string> landscape,
                                                              List <string> country, List <string> state, List <string> city, List <string> stage, string dateAdded1st, string dateAdded2nd, string dateReviewed1st, string dateReviewed2nd, string globalSearch)
        {
            SearchResultsVM searchResultsVM = new SearchResultsVM();

            searchResultsVM.UsersList    = GetListOfUsers(globalSearch);
            searchResultsVM.SearchString = globalSearch;

            //----------------------------------------------------------------------
            string      uid         = User.FindFirstValue(ClaimTypes.NameIdentifier);
            AspNetUsers thisAspUser = _context.AspNetUsers.Where(x => x.Id == uid).First();
            Users       thisUser    = _context.Users.Where(x => x.UserId == uid).First();

            ViewBag.AspUser = thisAspUser;
            ViewBag.User    = thisUser;

            Startups startups = await _seamedInDal.GetStartups();

            var rankedStartups = Ranking(startups, thisUser).ToList();

            ViewBag.Startups = rankedStartups;

            if (globalSearch != null)
            {
                Startups foundStartups = await _seamedInDal.GetFilteredStartUps(globalSearch.ToLower());

                List <Tuple <int, Record> > rankedStartupsFromGlobal = RankingVersion2(foundStartups, thisUser);

                searchResultsVM.ResultsList = rankedStartupsFromGlobal;

                return(View(searchResultsVM));
            }
            else
            {
                List <List <string> > listOfLists = new List <List <string> >();

                listOfLists.Add(source);
                listOfLists.Add(scout);
                listOfLists.Add(alignment);
                listOfLists.Add(theme);
                listOfLists.Add(technologyArea);
                listOfLists.Add(landscape);
                listOfLists.Add(country);
                listOfLists.Add(state);
                listOfLists.Add(city);
                listOfLists.Add(stage);

                List <string> convertedList = _seamedInDal.ConvertsListsOfFormSelection(listOfLists);
                Startups      foundStartups = await _seamedInDal.GetFilteredStartUps(convertedList);

                List <Tuple <int, Record> > rankedStartupsFromFilter = RankingVersion2(foundStartups, thisUser);

                searchResultsVM.ResultsList = rankedStartupsFromFilter;

                return(View(searchResultsVM));
            }
        }
        public IActionResult Individual(string id)
        {
            Record r = sd.GetRecord(id);

            Startups.RateIndividual(r);

            r.startups.Comments = _context.Comments.Where(x => x.CompanyName == r.startups.CompanyName && x.FavoriteId == null).ToList();

            return(View(r));
        }
        public async Task <IActionResult> Create([Bind("Id,Poster,Texts,Country,AboutProject")] Startups startups)
        {
            if (ModelState.IsValid)
            {
                _context.Add(startups);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(startups));
        }
        public IEnumerable <StartupRank> Ranking(Startups startups, Users user)
        {
            List <StartupRank> rankedList = new List <StartupRank>();



            //do algorithm and add to rankedList accordingly

            foreach (Record startup in startups.records)
            {
                int rank = 0;
                //if statements

                if (startup.fields.Country != null && user.Country != null && (startup.fields.Country == user.Country))
                {
                    rank += 1;
                }

                if (startup.fields.Alignment != null && user.Name != null && startup.fields.Alignment.Contains(user.Name))
                {
                    rank += 5;
                }

                if (startup.fields.Themes != null && user.Theme != null && startup.fields.Themes.Contains(user.Theme))
                {
                    rank += 3;
                }

                if (startup.fields.TechnologyAreas != null && user.Technology != null && startup.fields.TechnologyAreas.Contains(user.Technology))
                {
                    rank += 3;
                }

                if (startup.fields.Landscape != null && user.Landscape != null && startup.fields.Landscape == user.Landscape)
                {
                    rank += 4;
                }
                StartupRank s = new StartupRank(startup, rank);
                rankedList.Add(s);
            }

            IEnumerable <StartupRank> sortedStartups =
                from startup in rankedList
                orderby startup.Rank descending
                select startup;

            return(sortedStartups);
        }
        public async Task <IActionResult> AboutUs()
        {
            string uid = User.FindFirstValue(ClaimTypes.NameIdentifier);

            AspNetUsers thisAspUser = _context.AspNetUsers.Where(x => x.Id == uid).First();

            Users thisUser = _context.Users.Where(x => x.UserId == uid).First();

            ViewBag.AspUser = thisAspUser;

            ViewBag.User = thisUser;

            Startups startups = await _seamedInDal.GetStartups();

            var rankedStartups = Ranking(startups, thisUser).ToList();

            ViewBag.Startups = rankedStartups;
            return(View());
        }
        public async Task <SearchPageVM> GetStartUpColumnCategoryValues()
        {
            SearchPageVM searchPageVM   = new SearchPageVM();
            Startups     currentApiData = await _seamedInDal.GetStartups();

            foreach (Record startUp in currentApiData.records)
            {
                AddToRespectiveList(startUp.fields.Source, searchPageVM.sourcesList);
                AddToRespectiveList(startUp.fields.Scout, searchPageVM.scoutsList);
                AddToRespectiveList(startUp.fields.Landscape, searchPageVM.landscapesList);
                AddToRespectiveList(startUp.fields.Country, searchPageVM.countriesList);
                AddToRespectiveList(startUp.fields.StateProvince, searchPageVM.statesList);
                AddToRespectiveList(startUp.fields.City, searchPageVM.citiesList);
                AddToRespectiveList(startUp.fields.Stage, searchPageVM.stagesList);

                AddToRespectiveListMultiValue(startUp.fields.Alignment, searchPageVM.alignmentsList);
                AddToRespectiveListMultiValue(startUp.fields.Themes, searchPageVM.themesList);
                AddToRespectiveListMultiValue(startUp.fields.TechnologyAreas, searchPageVM.technologyAreasList);
            }

            return(searchPageVM);
        }
        public List <Tuple <int, Record> > RankingVersion2(Startups startups, Users userObject)
        {
            List <Tuple <int, Record> > RecordRankList = new List <Tuple <int, Record> >();

            foreach (Record startup in startups.records)
            {
                int rank = 0;
                #region Ranking Conditions
                if (startup.fields.Country != null && userObject.Country != null && (startup.fields.Country == userObject.Country))
                {
                    rank += 1;
                }
                if (startup.fields.Alignment != null && userObject.Name != null && startup.fields.Alignment.Contains(userObject.Name))
                {
                    rank += 5;
                }
                if (startup.fields.Themes != null && userObject.Theme != null && startup.fields.Themes.Contains(userObject.Theme))
                {
                    rank += 3;
                }
                if (startup.fields.TechnologyAreas != null && userObject.Technology != null && startup.fields.TechnologyAreas.Contains(userObject.Technology))
                {
                    rank += 3;
                }
                if (startup.fields.Landscape != null && userObject.Landscape != null && startup.fields.Landscape == userObject.Landscape)
                {
                    rank += 4;
                }
                #endregion
                RecordRankList.Add(new Tuple <int, Record>(rank, startup));
            }

            RecordRankList = RecordRankList.OrderByDescending(t => t.Item1).ToList();

            return(RecordRankList);
        }