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); }
public ActionResult DeleteConfirmed(string eircode) { CoffeeStore coffeeStore = db.CoffeeStores.Find(eircode); db.CoffeeStores.Remove(coffeeStore); db.SaveChanges(); return(RedirectToAction("StoreIndex")); }
// GET: CoffeeStores/Create public ActionResult Create() { CoffeeStore coffeestore = new CoffeeStore() { }; return(View(coffeestore)); }
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); }
public ActionResult Edit([Bind(Include = "Eircode,StoreName,City,Location,hasWifi,OpeningTime,ClosingTime")] CoffeeStore coffeeStore) { if (ModelState.IsValid) { db.Entry(coffeeStore).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("StoreIndex")); } return(View(coffeeStore)); }
public ActionResult Create([Bind(Include = "Eircode,StoreName,StoreRating,City,Location,hasWifi,OpeningTime,ClosingTime")] CoffeeStore coffeeStore) { if (ModelState.IsValid) { db.CoffeeStores.Add(coffeeStore); db.SaveChanges(); return(RedirectToAction("StoreIndex")); } return(View(coffeeStore)); }
// GET: CoffeeStores/Delete/5 public ActionResult Delete(string eircode) { if (eircode == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CoffeeStore coffeeStore = db.CoffeeStores.Find(eircode); if (coffeeStore == null) { return(HttpNotFound()); } return(View(coffeeStore)); }
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"); }
public void TestMethod1() { 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 }); Assert.AreEqual(charleys.StoreRating, 3); }
// 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()); }