Пример #1
0
        static void main()
        {
            DrinkContext db       = new DrinkContext();
            CoffeeStore  charleys = new CoffeeStore()
            {
                Eircode = "T12GH46", City = City.Dublin, OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1800, Location = "dublin fair city", StoreName = "charleys", hasWifi = true
            };
            List <Review> reviews = new List <Review>();

            reviews.Add(new Review()
            {
                CustomerName = "Stevo", CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It was great", Rating = 4
            });
            reviews.Add(new Review()
            {
                CustomerName = "john", CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It was great", Rating = 3
            });
            reviews.Add(new Review()
            {
                CustomerName = "pete", CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It wasn't great", Rating = 2
            });



            //my local connection string
            //Data Source=.\SQLEXPRESS;Initial Catalog=newDb;Integrated Security=SSPI;AttachDBFilename=C:\martin\data\coffeeDb.mdf
        }
Пример #2
0
        public void TestAddDrink()
        {
            CoffeeStore charleys = new CoffeeStore() { Eircode = "T12GH46", City = City.Dublin, OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1900, Location = "dublin fair city", StoreName = "charleys", hasWifi = true };
            Drink BubbleTea = new Drink() { DrinkName = "Bubble Tea", Price = 2.45, Eircode = charleys.Eircode };

            Assert.AreEqual(BubbleTea.DrinkName, "Bubble Tea");
            Assert.AreEqual(BubbleTea.Price, 2.45);
            Assert.AreEqual(BubbleTea.Eircode, "T12GH46");
        }
Пример #3
0
        static void main()
        {
            DrinkContext db = new DrinkContext();
            CoffeeStore charleys = new CoffeeStore() { Eircode = "T12GH46", City = City.Dublin, OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1800, Location = "dublin fair city", StoreName = "charleys", hasWifi = true };
            List<Review> reviews = new List<Review>();
            reviews.Add(new Review() { CustomerName = "Stevo", CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It was great", Rating = 4 });
            reviews.Add(new Review() { CustomerName = "john", CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It was great", Rating = 3 });
            reviews.Add(new Review() { CustomerName = "pete", CustomerEmail = "*****@*****.**", Eircode = charleys.Eircode, Comment = "It wasn't great", Rating = 2 });

            //my local connection string
            //Data Source=.\SQLEXPRESS;Initial Catalog=newDb;Integrated Security=SSPI;AttachDBFilename=C:\martin\data\coffeeDb.mdf
        }
Пример #4
0
 public void AddStore(CoffeeStore cs)
 {
     using (DrinkContext db = new DrinkContext())
     {
         try
         {
             db.CoffeeStores.Add(cs);
             db.SaveChanges();
         }
         catch (Exception e)
         { Console.WriteLine(e.ToString()); }
     }
 }
Пример #5
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);
        }
Пример #6
0
 public void TestIsOpen()
 {
     CoffeeStore charleys = new CoffeeStore() { Eircode = "T12GH46", City = City.Dublin, OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1900, Location = "dublin fair city", StoreName = "charleys", hasWifi = true };
     Assert.AreEqual(charleys.IsOpen, true);
 }
Пример #7
0
 // GET: CoffeeStores/Create
 public ActionResult Create()
 {
     CoffeeStore coffeestore = new CoffeeStore() { };
     return View(coffeestore);
 }
Пример #8
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();
        }
Пример #9
0
 public void AddStore(CoffeeStore cs)
 {
     using (DrinkContext db = new DrinkContext())
     {
         try
         {
             db.CoffeeStores.Add(cs);
             db.SaveChanges();
         }
         catch (Exception e)
         { Console.WriteLine(e.ToString()); }
     }
 }