Beispiel #1
0
        public void ShowCoffee(CoffeeShop coffee)
        {
            var coord      = new LatLng(coffee.Coordinates.Latitude, coffee.Coordinates.Longitude);
            var markerOpt1 = new MarkerOptions();

            markerOpt1.SetPosition(coord);
            markerOpt1.SetTitle(coffee.Name);


            var iconFactory = new IconGenerator(this.context);

            addIcon(iconFactory, coffee.Name, coord);

            var maker = map.AddMarker(markerOpt1);

            maker.ShowInfoWindow();

            var builder = CameraPosition.InvokeBuilder();

            builder.Target(coord);
            builder.Zoom(18);
            builder.Bearing(155);
            builder.Tilt(65);
            var cameraPosition = builder.Build();
            var cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);
        }
        public ActionResult DoEditCoffeeShop(int CSID, string Name, string Address, string Phone, HttpPostedFileBase LogoImagePath, string TitleAbout, string DescAbout, string TitleContact, string DescContact, string Email)
        {
            string fileName            = LogoImagePath.FileName;
            var    path                = Path.Combine(Server.MapPath("~/Assets/resource/img/"), fileName);
            string fileNameNoExtension = Path.GetFileNameWithoutExtension(fileName);
            string extension           = Path.GetExtension(fileName);
            int    temp                = 1;

            while (System.IO.File.Exists(path))
            {
                fileName = fileNameNoExtension + "Copy(" + temp + ")" + extension;
                path     = Path.Combine(Server.MapPath("~/Assets/resource/img/"), fileName);
                temp++;
            }
            LogoImagePath.SaveAs(path);
            string     imagePath  = "~/Assets/resource/img/" + fileName;
            CoffeeShop coffeeshop = new CoffeeShop();

            coffeeshop.CSID          = CSID;
            coffeeshop.Name          = Name;
            coffeeshop.Address       = Address;
            coffeeshop.Phone         = Phone;
            coffeeshop.LogoImagePath = imagePath;
            coffeeshop.TitleAbout    = TitleAbout;
            coffeeshop.DescAbout     = DescAbout;
            coffeeshop.TitleContact  = TitleContact;
            coffeeshop.DescContact   = DescContact;
            coffeeshop.Email         = Email;
            bool result = info.EditCoffeeShop(coffeeshop);

            return(RedirectToAction("GetAllCoffeeShop", "Web"));
        }
        public void total_miss_returns_null()
        {
            var shop = new CoffeeShop();

            theSession.MetadataFor(shop)
            .ShouldBeNull();
        }
Beispiel #4
0
        public async Task <ActionResult <CoffeeShop> > PostCoffeeShop(CoffeeShop coffeeShop)
        {
            _logger.LogInformation($"Creating coffee shop item: {coffeeShop.ToString()}");
            await _repository.AddCoffeeShop(coffeeShop);

            _logger.LogInformation($"Created coffee shop item: {coffeeShop.ToString()}");
            return(CreatedAtAction(nameof(GetCoffeeShop), new { id = coffeeShop.Id }, coffeeShop));
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            CoffeeShop CoffeeShop = db.CoffeeShops.Find(id);

            db.CoffeeShops.Remove(CoffeeShop);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public CoffeeShop GetCoffeeShopByID(int CSID)
        {
            CoffeeShop cs = (from coffeeshop in context.CoffeeShops
                             where coffeeshop.CSID == CSID
                             select coffeeshop).SingleOrDefault();

            return(cs);
        }
 public IActionResult Create([FromBody] CoffeeShop shop)
 {
     if (shop == null)
     {
         return(BadRequest());
     }
     CoffeeShops.Add(shop);
     return(CreatedAtRoute("GetCoffeeShop", new { id = shop.Key }, shop));
 }
Beispiel #8
0
 public ActionResult Edit([Bind(Include = "Id,CoffeeShopName,CoffeeShopAddress")] CoffeeShop CoffeeShop)
 {
     if (ModelState.IsValid)
     {
         db.Entry(CoffeeShop).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(CoffeeShop));
 }
        public static void RunEx10_13()
        {
            FastFood   krystal   = new FastFood("Krystal");
            CoffeeShop starbucks = new CoffeeShop("Starbucks");
            Fancy      snooty    = new Fancy("Snooty Grill");

            krystal.EatOut();
            starbucks.EatOut();
            snooty.EatOut();
        }
Beispiel #10
0
        public void Ctor1()
        {
            // Arrange
            var data = new[] { new Coffee("Espresso"), new Coffee("Espresso"), new Coffee("Royal"), new Coffee("Royal"), new Coffee("Espresso"), new Coffee("Tasty"), new Coffee("Mocha"), };
            var sut  = new CoffeeShop(data);

            // Act
            // Assert
            Assert.IsTrue(data.GroupBy(x => x).All(x => x.Count() == data.Count(c => c.Equals(x.First()))));
        }
Beispiel #11
0
        private View DelegatedGetCoffeeShopViewCreation(int position, CoffeeShop shop, View convertView)
        {
            View view = convertView ?? Activity.LayoutInflater.Inflate(Resource.Layout.RowCoffeeShop, null);

            var name    = view.FindViewById <TextView>(Resource.Id.coffee_name);
            var address = view.FindViewById <TextView>(Resource.Id.coffee_address);

            name.Text    = shop.Name;
            address.Text = shop.Address;
            return(view);
        }
Beispiel #12
0
 public CoffeeShopScenario()
 {
     _shop          = new CoffeeShop();
     _cmdDispatcher = new Dictionary <Type, Action <Command> >()
     {
         [typeof(MakeFlatWhite)] = c => _shop.MakeFlatwhite(),
         [typeof(MakeAmericano)] = c => _shop.MakeAmericano(),
         [typeof(DeliverCoffee)] = c => _shop.ReceiveCoffee(((DeliverCoffee)c).Amount),
         [typeof(DeliverMilk)]   = c => _shop.ReceiveCoffee(((DeliverMilk)c).Amount)
     };
 }
Beispiel #13
0
        public ActionResult Create([Bind(Include = "Id,CoffeeShopName,CoffeeShopAddress")] CoffeeShop CoffeeShop)
        {
            if (ModelState.IsValid)
            {
                db.CoffeeShops.Add(CoffeeShop);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(CoffeeShop));
        }
 public IActionResult Output(CoffeeShop coffeeShop)
 {
     ViewData["FirstName"] = coffeeShop.FirstName;
     ViewData["LastName"]  = coffeeShop.LastName;
     ViewData["Email"]     = coffeeShop.Email;
     ViewData["Password"]  = coffeeShop.Password;
     ViewData["Venilla"]   = coffeeShop.Venilla;
     ViewData["Mocha"]     = coffeeShop.Mocha;
     ViewData["Caramel"]   = coffeeShop.Cramel;
     return(View());
 }
Beispiel #15
0
        public async Task DeleteCoffeeShop(long id)
        {
            CoffeeShop coffeeShop = await GetById(id);

            if (coffeeShop == null)
            {
                throw new CoffeeShopNotFoundException(id.ToString());
            }

            _context.CoffeeShops.Remove(coffeeShop);
            await _context.SaveChangesAsync();
        }
 public CoffeeShopScenarioRunner()
 {
     _shop          = new CoffeeShop();
     _cmdDispatcher = new Dictionary <Type, Action <Command> >()
     {
         [typeof(MakeFlatWhite)] = c => _shop.MakeFlatwhite(),
         [typeof(MakeAmericano)] = c => _shop.MakeAmericano(),
         [typeof(DeliverCoffee)] = c => _shop.ReceiveCoffee(((DeliverCoffee)c).Amount),
         [typeof(DeliverMilk)]   = c => _shop.ReceiveCoffee(((DeliverMilk)c).Amount)
     };
     this.Configure(cfg => cfg.IgnoreAll("Id"));
 }
Beispiel #17
0
        public void AddCoffee()
        {
            // Arrange
            var data = new[] { new Coffee("Espresso"), new Coffee("Espresso"), new Coffee("Royal"), new Coffee("Royal"), new Coffee("Espresso"), new Coffee("Tasty"), new Coffee("Mocha"), };
            var sut  = new CoffeeShop(data, 4);

            // Act
            Assert.IsTrue(sut.AddCoffee(new Coffee("Random")));
            Assert.IsTrue(sut.AddCoffee(new Coffee("Random")));
            // Assert
            Assert.IsTrue(sut.CoffeesReadyToServe[new Coffee("Random")] == 2);
            Assert.IsTrue(sut.CoffeesServed == 0);
        }
Beispiel #18
0
        public async Task <ActionResult <CoffeeShop> > GetCoffeeShop(long id)
        {
            _logger.LogInformation($"Getting coffee shop item with id: {id}");
            CoffeeShop coffeeShop = await _repository.GetById(id);

            if (coffeeShop != null)
            {
                _logger.LogInformation($"Returning coffee shop item: {coffeeShop.ToString()}");
                return(Ok(coffeeShop));
            }

            _logger.LogInformation($"Not found coffee shop item: {id}");
            return(NotFound());
        }
Beispiel #19
0
        // GET: CoffeeShop/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CoffeeShop CoffeeShop = db.CoffeeShops.Find(id);

            if (CoffeeShop == null)
            {
                return(HttpNotFound());
            }
            return(View(CoffeeShop));
        }
Beispiel #20
0
        public IActionResult Create([FromBody] CoffeeShop item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.coffeeShops.Add(item);
            _context.SaveChanges();

            //return CreatedAtRoute("GetCoffeeShop", new CoffeeShop{Id = item.Id});

            return(NoContent());
        }
Beispiel #21
0
 public bool DeleteCoffeeShop(int CSID)
 {
     try
     {
         CoffeeShop cs = context.CoffeeShops.Single(m => m.CSID == CSID);
         context.CoffeeShops.DeleteOnSubmit(cs);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw new Exception("Error delete " + e.Message);
     }
 }
Beispiel #22
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CoffeeShop = await _context.CoffeeShop.SingleOrDefaultAsync(m => m.ID == id);

            if (CoffeeShop == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #23
0
        public void TestMethod1()
        {
            var data = new CoffeeShop();

            data.Reviews = new List <ShopReviews>();
            data.Reviews.Add(new ShopReviews()
            {
                ratings = 4
            });

            var rateIndicator = new ShopRater(data);
            var result        = rateIndicator.ComputeRating(10);

            Assert.AreEqual(4, result.Rating);
        }
Beispiel #24
0
        public void AddCustomer()
        {
            // Arrange
            var data = new[] { new Coffee("Espresso"), new Coffee("Espresso"), new Coffee("Royal"), new Coffee("Royal"), new Coffee("Espresso"), new Coffee("Tasty"), new Coffee("Mocha"), };
            var sut  = new CoffeeShop(data, 4);

            // Act
            sut.AddCustomer();
            Assert.IsTrue(sut.CustomersInQueue.Count == 5);
            sut.AddCustomer();
            // Assert
            Assert.IsTrue(data.GroupBy(x => x).All(x => x.Count() == data.Count(c => c.Equals(x.First()))));
            Assert.IsTrue(sut.CustomersInQueue.Count == 6);
            Assert.IsTrue(sut.NextTicket == 7);
            Assert.IsTrue(sut.NextTicket == 7);
        }
Beispiel #25
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CoffeeShop = await _context.CoffeeShop.FindAsync(id);

            if (CoffeeShop != null)
            {
                _context.CoffeeShop.Remove(CoffeeShop);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public IActionResult Update(string id, [FromBody] CoffeeShop shop)
        {
            if (shop == null || shop.Key != id)
            {
                return(BadRequest());
            }

            var theShop = CoffeeShops.Find(id);

            if (theShop == null)
            {
                return(NotFound());
            }

            CoffeeShops.Update(shop);
            return(new NoContentResult());
        }
        public void hit_returns_values()
        {
            var shop = new CoffeeShop();

            using (var session = theStore.OpenSession())
            {
                session.Store(shop);
                session.SaveChanges();
            }

            using (var session = theStore.QuerySession())
            {
                var metadata = session.MetadataFor(shop);

                metadata.ShouldNotBeNull();
                metadata.CurrentVersion.ShouldNotBe(Guid.Empty);
                metadata.LastModified.ShouldNotBe(default);
        public IActionResult Index()
        {
            // 13.3.1 Passing data to a template using the key "testProperty"
            ViewBag.testProperty = "LaunchCode";

            // 13.4 Iterating in a template
            List <String> fruits = new List <string>
            {
                "Apple",
                "Banana",
                "Orange",
                "Pineapple"
            };

            ViewBag.fruits = fruits;

            // 13.4.1 Nested Loops
            CoffeeShop cs1 = new CoffeeShop
            {
                Name          = "Central Perk",
                CoffeeOptions = new List <string>
                {
                    "Espresso",
                    "Instant"
                }
            };

            CoffeeShop cs2 = new CoffeeShop
            {
                Name          = "Brews Brothers",
                CoffeeOptions = new List <string>
                {
                    "French Roast",
                    "Kopi Luwak"
                }
            };

            ViewBag.coffeeShops = new List <CoffeeShop> {
                cs1, cs2
            };

            // 13.5.1 Display content if/else
            ViewBag.awesome = true;

            return(View());  // Note: This will look for a .cshtml file called Index in the Hello folder
        }
Beispiel #29
0
        public void ShowCoffee(CoffeeShop coffee)
        {
            var coord = new CoreLocation.CLLocationCoordinate2D(
                coffee.Coordinates.Latitude,
                coffee.Coordinates.Longitude
                );
            var annotation = new MKPointAnnotation {
                Title      = coffee.Name,
                Coordinate = coord
            };

            this.map.AddAnnotation(annotation);
            this.map.ShowAnnotations(new IMKAnnotation[] { annotation }, true);
            this.map.SelectAnnotation(annotation, true);

            var span = new MKCoordinateSpan(.01f, .01f);

            map.Region = new MKCoordinateRegion(coord, span);
        }
Beispiel #30
0
        public void ShowCoffee(CoffeeShop coffee)
        {
            var position = new Position(
                coffee.Coordinates.Latitude,
                coffee.Coordinates.Longitude
                );         // Latitude, Longitude

            var pin = new Pin {
                Type     = PinType.Place,
                Position = position,
                Label    = coffee.Name,
                Address  = coffee.Address
            };

            this.map.Pins.Add(pin);
            this.map.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                    position, Distance.FromMiles(.1)));
        }
Beispiel #31
0
        public string PrintTable(CoffeeShop[] shops)
        {
            StringBuilder result = new StringBuilder();
            result.Append("Count = " + shops.Length);

            result.Append("<table>");
            result.Append("<tr><th>Id</th><th>Name</th><th>Phone</th></tr>");
            //foreach (CoffeeShop shop in shops)
            for (int i = 0; i < shops.Length; i++)
            {
                string backgroundColor;
                switch (shops[i].Open)
                {
                    case 600:
                        backgroundColor = "lawngreen";
                        break;
                    case 700:
                        backgroundColor = "lightgreen";
                        break;
                    case 730:
                        backgroundColor = "forestgreen";
                        break;
                    case 800:
                        backgroundColor = "darkgreen";
                        break;
                    default:
                        backgroundColor = "white";
                        break;
                }
                result.Append("<tr style='background-color:" + backgroundColor + "'>"
                    + "<td>" + (i+1) + "</td><td>"
                    + shops[i].DisplayName + "</td><td>" + shops[i].Phone + "</td></tr>");
            }
            result.Append("</table>");

            return result.ToString();
        }