Exemplo n.º 1
0
        public ActionResult Product()
        {
            maedbEntities2  Members      = new maedbEntities2();
            List <Souvenir> AllSouvenirs = Members.Souvenirs.ToList();

            ViewBag.EmpList = AllSouvenirs;



            return(View("Contact"));
        }
Exemplo n.º 2
0
        public ActionResult Member()
        {
            //call the API using the URL. thia can be done by using HTTP requests and responses

            HttpWebRequest WR = WebRequest.CreateHttp("http://forecast.weather.gov/MapClick.php?lat=42.3331&lon=-83.0496&FcstType=json");

            WR.UserAgent = @"User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36";

            HttpWebResponse Response = (HttpWebResponse)WR.GetResponse();

            StreamReader reader = new StreamReader(Response.GetResponseStream()); //get a reference to the response stream

            string WeatherData = reader.ReadToEnd();                              // reads the data and stores it in the string

            JObject JsonData = JObject.Parse(WeatherData);

            ViewBag.Weather = JsonData["data"]["weather"];

            ViewBag.Time = JsonData["time"]["startPeriodName"];

            ViewBag.Temp = JsonData["data"]["temperature"];

            ViewBag.Text = JsonData["data"]["text"];

            ///////////////////////////////////////////////////
            maedbEntities2 Members = new maedbEntities2();

            List <Event> UserEvent = Members.Events.ToList();
            List <Food>  UserFood  = Members.Foods.ToList();


            // random number generator
            Random rnd     = new Random(Guid.NewGuid().GetHashCode()); //generates a new sequence each time the method is called
            int    Number1 = rnd.Next(1, UserEvent.Count);

            //Random rnd2 = new Random(Guid.NewGuid().GetHashCode());
            int Number2 = rnd.Next(1, UserFood.Count);

            ViewBag.EventData = UserEvent[Number1];
            /////////////////
            ViewBag.FoodData = UserFood[Number2];

            return(View());
        }
Exemplo n.º 3
0
        public ActionResult AddtoCart(string Souvenir)
        {
            List <Souvenir> ShoppingBag; // reference to null

            if (Session["Cart"] == null) // the cart is empty!
            {
                Session.Add("Cart", new List <Souvenir>());

                ShoppingBag = new List <Souvenir>();
            }

            else// user has items in the cart, so go and retrive it!
            {
                ShoppingBag = (List <Souvenir>)Session["Cart"];
            }
            ///////////////////////////
            maedbEntities2 ItemList = new maedbEntities2();


            Souvenir Option = ItemList.Souvenirs.Find(Souvenir);

            ShoppingBag.Add(Option);

            Session["Cart"] = ShoppingBag;// save changes you made to your cart!

            ViewBag.Cart = ShoppingBag;

            maedbEntities2  NewList     = new maedbEntities2();
            List <Souvenir> AllProducts = NewList.Souvenirs.ToList();

            ViewBag.PList = AllProducts;



            return(RedirectToAction("Product"));
        }