Пример #1
0
        // GET: Review/Create
        public ActionResult Create()
        {
            Review review = new Review() { Rating = 4, ReviewDate = DateTime.Now };
            ViewBag.Eircode = new SelectList(db.CoffeeStores, "Eircode", "StoreName");

            return View(review);
        }
Пример #2
0
        public void TestAddReview()
        {
            CoffeeStore charleys = new CoffeeStore() { Eircode = "T12GH46", City = City.Dublin, OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1800, Location = "dublin fair city", StoreName = "charleys", hasWifi = true };

            Review a = new Review() { CustomerName = "Stevo", ReviewDate = DateTime.Today, CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It was great", Rating = 4 };
            Review b = new Review() { CustomerName = "john", ReviewDate = DateTime.Today, CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It was great", Rating = 3 };
            Review c = new Review() { CustomerName = "pete", ReviewDate = DateTime.Today, CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It wasn't great", Rating = 2 };

            Assert.AreEqual(a.CustomerName, "Stevo");
            Assert.AreEqual(a.CustomerEmail, "*****@*****.**");
            Assert.AreEqual(a.Eircode, charleys.Eircode);
            Assert.AreEqual(a.Rating, 4);
            Assert.AreEqual(a.Comment, "It was great");
               Assert.AreEqual(a.ReviewDate, DateTime.Today);
        }
Пример #3
0
 public ActionResult ContactCustomer(String message, Review review)
 {
     ViewBag.Message = "Message to customer has been sent!";
     return View();
 }
Пример #4
0
        // Do Entity Framework code first
        public ActionResult DoCodeFirst()
        {
            DrinkRepository repository = new DrinkRepository();

            CoffeeStore st1 = new CoffeeStore() { Eircode = "C15C98E", City = City.Limerick, Location = "O' Connell St. Limerick", OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1730, StoreName = "Starbucks", Reviews = new List<Review>(), Drinks = new List<Drink>() };
            CoffeeStore co1 = new CoffeeStore() { Eircode = "C15CK3E", City = City.Limerick, Location = "William st.. Limerick", OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1730, StoreName = "Costa", Reviews = new List<Review>(), Drinks = new List<Drink>() };
            CoffeeStore in1 = new CoffeeStore() { Eircode = "C15C01E", City = City.Limerick, Location = "Cecil St. Limerick", OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1730, StoreName = "Insomnia", Reviews = new List<Review>(), Drinks = new List<Drink>() };
            repository.AddStore(st1);
            repository.AddStore(co1);
            repository.AddStore(in1);

            Drink latte = new Drink() { DrinkName = "Cafe Latte", Price = 3.40, Eircode = co1.Eircode };
            Review r1 = new Review() { CustomerName = "mg1", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "The coffee is way too expensive", Rating = 4, Eircode = co1.Eircode };
            Review r2 = new Review() { CustomerName = "mg5", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "The service was shocking", Rating = 4, Eircode = st1.Eircode };
            Review r3 = new Review() { CustomerName = "mj3", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "The coffee was best in Dublin", Rating = 4, Eircode = st1.Eircode };
            Review r4 = new Review() { CustomerName = "keith",CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "They had a wide variety of coffees", Rating = 4, Eircode = st1.Eircode };
            repository.AddDrink(latte);
            repository.AddReview(r1);
            repository.AddReview(r2);
            repository.AddReview(r3);
            repository.AddReview(r4);
            Drink Mocha = new Drink() { DrinkName = "Mocha", Price = 3.70, Eircode = st1.Eircode };
            Drink Frappacino = new Drink() { DrinkName = "Frappacino", Price = 4.40, Eircode = st1.Eircode };
            Drink IceCafelatte = new Drink() { DrinkName = "Ice Cafe Latte", Price = 3.40, Eircode = st1.Eircode };
            repository.AddDrink(Mocha);
            repository.AddDrink(Frappacino);
            repository.AddDrink(IceCafelatte);

            ViewBag.Words = new List<string> { "codeFirst", "completed" };
            return View();
        }
Пример #5
0
 public void AddReview(Review review)
 {
     using (DrinkContext db = new DrinkContext())
     {
         try
         {
             db.Reviews.Add(review);
             db.SaveChanges();
         }
         catch (Exception e)
         { Console.WriteLine(e.ToString()); }
     }
 }