示例#1
0
        public IActionResult OnDetail(Detail model)
        {
            Favorite favorite = new Favorite(HttpContext.Session);

            List <OlyCountry> Favorite = favorite.AddFavorite();

            OlyCountry olyCountry = Context.OlyCountries.Include(t => t.OlySport).Include(t => t.OlyCat).Include(t => t.OlyGame).FirstOrDefault(t => t.OlyCountryID == model.OlyCountry.OlyCountryID);

            if (Favorite != null)
            {
                if (Favorite.Find(t => t.OlyCountryID == model.OlyCountry.OlyCountryID) == null)
                {
                    Favorite.Add(olyCountry);
                    favorite.SaveFavorite(Favorite);
                }
            }
            else
            {
                Favorite = new List <OlyCountry>();
                Favorite.Add(olyCountry);
                favorite.SaveFavorite(Favorite);
            }

            RouteValueDictionary favoriteValue = new RouteValueDictionary()
            {
                { "name", olyCountry.OlyCountryName }
            };

            return(RedirectToAction("OnDetail", "Home", favoriteValue));
        }
示例#2
0
        public IActionResult Favorite()
        {
            Favorite          favorite = new Favorite(HttpContext.Session);
            List <OlyCountry> model    = favorite.AddFavorite();

            return(View(model));
        }
示例#3
0
        /// <summary>
        /// ふぁぼります
        /// </summary>
        /// <param name="TweetId">ふぁぼるツイートのID</param>
        public void AddFavorite(string TweetId)
        {
            var f = new Favorite();

            try
            {
                f.AddFavorite(TweetId);
            }
            catch { throw; }
        }
示例#4
0
        // Pulling all my data from my database and storing them into
        // list form for user view and interaction.
        public ViewResult Index(string activeOlyCat = "all", string activeOlyGame = "all", string activeOlySport = "all")
        {
            Favorite favorite = new Favorite(HttpContext.Session);

            ViewBag.Favorite = favorite.AddFavorite();

            ViewBag.ActiveOlyCat   = activeOlyCat;
            ViewBag.ActiveOlyGame  = activeOlyGame;
            ViewBag.ActiveOlySport = activeOlySport;

            List <OlyCat>   olyCats   = Context.OlyCats.ToList();
            List <OlyGame>  olyGames  = Context.OlyGames.ToList();
            List <OlySport> olySports = Context.OlySports.ToList();

            olyGames.Insert(0, new OlyGame {
                OlyGameID = "all", OlyGameName = "All"
            });
            olyCats.Insert(0, new OlyCat {
                OlyCatID = "all", OlyCatName = "All"
            });
            olySports.Insert(0, new OlySport {
                OlySportID = "all", OlySportName = "All"
            });

            ViewBag.OlyGames  = olyGames;
            ViewBag.OlyCats   = olyCats;
            ViewBag.OlySports = olySports;

            // Iquerable for showing countries associated w/ chosen item.
            IQueryable <OlyCountry> query = Context.OlyCountries;

            if (activeOlyGame != "all")
            {
                query = query.Where(
                    t => t.OlyGame.OlyGameID.ToLower() == activeOlyGame.ToLower());
            }

            if (activeOlyCat != "all")
            {
                query = query.Where(
                    t => t.OlyCat.OlyCatID.ToLower() == activeOlyCat.ToLower());
            }

            if (activeOlySport != "all")
            {
                query = query.Where(
                    t => t.OlySport.OlySportID.ToLower() == activeOlySport.ToLower());
            }

            var olyCountries = query.ToList();

            return(View(olyCountries));
        }
示例#5
0
        public void Can_Add_New_Lines()
        {
            //Arrange - create some test movies
            Movie p1 = new Movie {
                MovieId = 1, Title = "P1"
            };
            Movie p2 = new Movie {
                MovieId = 2, Title = "P2"
            };

            //Arrange - create a new favorite
            Favorite target = new Favorite();

            //Act - performing the test
            target.AddFavorite(p1, 1);
            target.AddFavorite(p2, 1);
            FavoriteLine[] results = target.Lines.ToArray();

            //Assert - Verifying that the result was the one that was required.
            Assert.AreEqual(results.Length, 2);
            Assert.AreEqual(results[0].Movie, p1);
            Assert.AreEqual(results[1].Movie, p2);
        }
示例#6
0
        public IActionResult OnDetail(string name)
        {
            Favorite favorite = new Favorite(HttpContext.Session);

            OlyCountry olyCountry = Context.OlyCountries.Include(t => t.OlySport).Include(t => t.OlyCat).Include(t => t.OlyGame).SingleOrDefault(t => t.OlyCountryName.ToLower() == name.ToLower());

            Detail model = new Detail()
            {
                OlyCountry   = olyCountry,
                Favorite     = favorite.FavoriteValid(olyCountry),
                FavoriteList = favorite.AddFavorite()
            };

            return(View(model));
        }