public async Task <IActionResult> DisplayListOfFavoriteStartUps()
        {
            var model = new FavoritesListVM();

            string id = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var    favoritesOfUser = await _context.Favorites.Where(x => x.UserId == id).ToListAsync();

            foreach (Favorites favorites in favoritesOfUser)
            {
                var favorite = await _seamedInDal.GetStartUpById(favorites.ApiId.ToString());

                FavoritesModel favoriteModel = new FavoritesModel();
                favoriteModel.ApiId           = int.Parse(favorite.id);
                favoriteModel.CompanyName     = favorite.fields.CompanyName;
                favoriteModel.City            = favorite.fields.City;
                favoriteModel.Country         = favorite.fields.Country;
                favoriteModel.Themes          = favorite.fields.Themes;
                favoriteModel.TechnologyAreas = favorite.fields.TechnologyAreas;
                favoriteModel.Landscape       = favorite.fields.Landscape;
                favoriteModel.StateProvince   = favorite.fields.StateProvince;

                model.ListOfFavoriteStartUps.Add(favoriteModel);
            }

            return(View(model));
        }
Exemple #2
0
        //Displays list of User's favorite StartUps
        //[Authorize]
        //public async Task<IActionResult> DisplayListOfFavoriteStartUps()
        //{
        //    var model = new FavoritesListVM();

        //    string id = User.FindFirstValue(ClaimTypes.NameIdentifier);
        //    var favoritesOfUser = await _context.Favorites.Where(x => x.UserId == id).ToListAsync();

        //    foreach (Favorites favorites in favoritesOfUser)
        //    {
        //        var favorite = await _seamedInDal.GetStartUpById(favorites.ApiId.ToString());

        //        FavoritesModel favoriteModel = new FavoritesModel();
        //        favoriteModel.ApiId = int.Parse(favorite.id);
        //        favoriteModel.CompanyName = favorite.fields.CompanyName;
        //        favoriteModel.City = favorite.fields.City;
        //        favoriteModel.Country = favorite.fields.Country;
        //        favoriteModel.Themes = favorite.fields.Themes;
        //        favoriteModel.TechnologyAreas = favorite.fields.TechnologyAreas;
        //        favoriteModel.Landscape = favorite.fields.Landscape;
        //        favoriteModel.StateProvince = favorite.fields.StateProvince;

        //        model.ListOfFavoriteStartUps.Add(favoriteModel);
        //    }

        //    return View(model);
        //}

        //favorite action method to find list of user's favorites
        public async Task <IActionResult> Favorites(FavoritesListVM favoritesListVM)
        {
            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);
            }
            favoritesListVM.ListofRecords = records;
            return(View(favoritesListVM));
        }
Exemple #3
0
        public IActionResult AddComment(string id, string comment)
        {
            string    uid   = User.FindFirstValue(ClaimTypes.NameIdentifier);
            Favorites found = _context.Favorites.FirstOrDefault(x => (x.ApiId == id) && (x.UserId == uid));

            found.CommentSection = comment;
            FavoritesListVM favoritesListVM = new FavoritesListVM();

            favoritesListVM.ListOfFavoriteStartUps.Add(found);
            _context.Entry(found).State = EntityState.Modified;
            _context.Update(found);
            _context.SaveChanges();
            return(RedirectToAction("Favorites", favoritesListVM));
        }