Beispiel #1
0
        public ActionResult Create(SoftDrink softDrink, HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                var fileName = Path.GetFileName(file.FileName);
                var path     = Path.Combine(Server.MapPath("~/Resources/"), fileName);
                file.SaveAs(path);
                softDrink.ImagePath = "/Resources/" + fileName;
            }
            else
            {
                softDrink.ImagePath = "/Resources/default_softdrink.png";
            }

            db.SoftDrinks.Add(softDrink);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        private static void AddSoftDrink(IVendingMachine machine, int amount)
        {
            SoftDrink softDrink = new SoftDrink();

            machine.AddItem(softDrink, amount);
        }
Beispiel #3
0
 public TangoBuilder()
 {
     SoftDrink = new SoftDrink("Tango");
 }
 public BuySoftDrinkResult(bool isPurchased, SoftDrink softDrink = null, string errorMessage = null)
 {
     this.IsPurchased  = isPurchased;
     this.SoftDrink    = softDrink;
     this.ErrorMessage = errorMessage;
 }
 public FantaBuilder()
 {
     SoftDrink = new SoftDrink("Fanta");
 }