Example #1
0
 private static void InitializeOrders(ApplicationDbContext context)
 {
     if (context.Orders.Any())
     {
         return;
     }
     if (context.Employees.Any())
     {
         Employee emp = context.Employees.First();
         Sandwich san = new Sandwich {
             Id = 1
         };
         OrderLine ordLin = new OrderLine {
             Quantity = 1, Sandwich = san
         };
         List <OrderLine> ordLinList = new List <OrderLine>();
         ordLinList.Add(ordLin);
         Order ord = new Order {
             DateOfDelivery = DateTime.Today, TotalAmount = (decimal)1.00, OrderLines = ordLinList
         };
         List <Order> ordList = new List <Order>();
         ordList.Add(ord);
         emp.Orders = ordList;
         //context.Orders.Add(ord);
         context.SaveChanges();
     }
 }
        void Start()
        {
            Person person = new Person();

            person.Name = "Bob";

            var apple = new Apple();

            person.Eat(apple);

            var cookie = new Cookie();

            person.Eat(cookie);

            var donut = new Donut();

            person.Eat(donut);

            var pancake = new Pancake();

            person.Eat(pancake);

            var sandwich = new Sandwich();

            person.Eat(sandwich);

            var steak = new Steak();

            person.Eat(steak);
        }
Example #3
0
    public static void Main()
    {
        var sandwich = new Sandwich();

        Console.WriteLine(sandwich);
        sandwich.Cook();
    }
Example #4
0
        public void WrongIngredientsOrder1()
        {
            var sandwich = new Sandwich();

            sandwich.Add(salad);
            Assert.AreEqual(sandwich.Vegetables, null);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Sandwich sandwich = db.Sandwiches.Find(id);

            db.Sandwiches.Remove(sandwich);
            db.SaveChanges();
            string        conString = ConfigurationManager.ConnectionStrings["InventoryContext"].ConnectionString.ToString();
            SqlConnection conn      = null;

            conn = new SqlConnection(conString);
            conn.Open();
            //int sandwichId = id;

            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@var1", id);
                cmd.CommandText = "DELETE FROM SandwichIngredient WHERE Sandwich_ID=@var1";

                //cmd.Parameters.AddWithValue("@var2", ingredient[i]);
                int rowsAffected = cmd.ExecuteNonQuery();
            }
            return(RedirectToAction("Index"));
        }
Example #6
0
        public IActionResult Make(string type, int?stack)
        {
            //string myType = Request.Query["type"];
            Sandwich yum = new Sandwich();

            yum.PattyCount = 1;
            if (stack != null)
            {
                yum.PattyCount = (int)stack > 0 ? (int)stack : 1;
            }
            if (type == "Chicken")
            {
                yum.Type = Sandwich.Types.Chicken;
            }
            else if (type == "Burger")
            {
                yum.Type = Sandwich.Types.Burger;
            }
            else if (type == "Meatless")
            {
                yum.Type = Sandwich.Types.Meatless;
            }
            else
            {
            }
            return(View(yum));
        }
        public void TurkeySandwichMachineTest()
        {
            SandwichMachine machine  = new SandwichMachine();
            Sandwich        sandwich = machine.CreateSandwich(new TurkeySandwichBuilder());

            Assert.AreEqual(String.Format("{0} with {1} on {2} bread", "Sliced Turkey", "Mayonaise", "White"), sandwich.ToString());
        }
        public void MeatballSandwichMachineTest()
        {
            SandwichMachine machine  = new SandwichMachine();
            Sandwich        sandwich = machine.CreateSandwich(new MeatBallSandwichBuilder());

            Assert.AreEqual(String.Format("{0} with {1} on {2} bread", "Meatballs", "Tomato Sauce", "Italian"), sandwich.ToString());
        }
Example #9
0
        public ActionResult Index(Sandwich newOrder)
        {
            double[] subPrice   = new double[] { 3.99, 3.99, 5.99, 6.99, 7.99, 8.99, 9.99 };
            String   subName    = Enum.GetName(typeof(subName), newOrder.subName_);
            var      priceOfSub = subPrice[(int)newOrder.subName_];

            double[] sizePrice   = new double[] { 3, 4, 5, 6, 7 };
            String   sizeName    = Enum.GetName(typeof(sizeName), newOrder.sizeName_);
            var      priceOfSize = sizePrice[(int)newOrder.sizeName_];

            double[] mealDeals   = new double[] { 0, 3.99, 4.99 };
            String   dealName    = Enum.GetName(typeof(mealDealName), newOrder.mealDealName_);
            var      priceOfDeal = mealDeals[(int)newOrder.mealDealName_];

            double total      = priceOfSub * priceOfSize + priceOfDeal;
            double tax        = total * .15;
            double finalTotal = tax + total;

            ViewBag.Tax        = Math.Round(tax, 2);
            ViewBag.Cost       = Math.Round(total, 2);
            ViewBag.Sub        = subName;
            ViewBag.PriceSub   = Math.Round(priceOfSub, 2);
            ViewBag.Size       = sizeName;
            ViewBag.PriceSize  = Math.Round(priceOfSize, 2);
            ViewBag.Deal       = dealName;
            ViewBag.PriceDeal  = Math.Round(priceOfDeal, 2);
            ViewBag.FinalTotal = Math.Round(finalTotal, 2);


            return(View("Receipt"));
        }
        /// <summary>
        /// Creates a new sandwich
        /// </summary>
        /// <param name="sandwich">Sandwich to create</param>
        /// <returns>Id of the new created sandwich</returns>
        public async virtual Task <int> SandwichCreate(Sandwich sandwich)
        {
            //Map the DTO to entities
            SANDWICH sandwichBase = _mapper.Map <SANDWICH>(sandwich);

            using (IUnitOfWork uow = new UnitOfWork((DbContext)Activator.CreateInstance(_contextType)))
            {
                //Get a new sequence's value
                sandwichBase.Id = uow.GetNextValInSequence <int>("SANDWICH_SEQUENCE");

                //Save the data
                uow.SandwichRepository.Create(sandwichBase);

                int sandwichId = sandwichBase.Id;

                foreach (Ingredient ingredient in sandwich.Ingredients)
                {
                    SANDWICH_INGREDIENT data = new SANDWICH_INGREDIENT()
                    {
                        Id           = uow.GetNextValInSequence <int>("SANDWICH_INGREDIENT_SEQUENCE"),
                        IngredientId = ingredient.Id,
                        SandwichId   = sandwichId
                    };

                    uow.SandwichIngredientRepository.Create(data);
                }

                //Commit the changes
                await uow.CommitAsync();
            }

            return(sandwichBase.Id);
        }
Example #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ShortDesc,LongDesc,Price,SalePrice,IsSandwichOfWeek")] Sandwich sandwich)
        {
            if (id != sandwich.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sandwich);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SandwichExists(sandwich.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sandwich));
        }
Example #12
0
        private async Task <DialogTurnResult> AddMySandwichStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var orderData = await _orderDataAccessor.GetAsync(stepContext.Context, () => new OrderData(), cancellationToken);

            if ((string)stepContext.Values["setmenu"] != "단품")
            {
                stepContext.Values["setdrink"] = ((FoundChoice)stepContext.Result).Value;
                orderData.SetMenu  = (string)stepContext.Values["setmenu"];
                orderData.SetDrink = (string)stepContext.Values["setdrink"];
            }

            Sandwich sandwich = new Sandwich(orderData.Menu, orderData.Bread, orderData.Cheese, orderData.Warmup, orderData.Topping, orderData.Vege, orderData.Sauce, orderData.SetMenu, orderData.SetDrink);

            orderData.Sandwiches.Add(sandwich);
            orderData.Num++;

            return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                                 new PromptOptions
            {
                Prompt = MessageFactory.Text("지금 만든 샌드위치 조합 저장할까요?"),
                Choices = ChoiceFactory.ToChoices(new List <string> {
                    "네", "아니오"
                }),
            }, cancellationToken));
        }
        public bool ComposeSandwish(Sandwich sandwishToUse, Ingredient ingredientsToAdd)
        {
            using (var ctx = new PortalContext())
            {
                if (!ctx.Sandwiches.Any(x => x.Name == sandwishToUse.Name))
                {
                    throw new Exception(nameof(sandwishToUse));
                }
                ctx.Sandwiches.Attach(sandwishToUse);

                if (ctx.Entry(ingredientsToAdd).State == EntityState.Detached)
                {
                    ctx.Ingredients.Attach(ingredientsToAdd);
                }

                sandwishToUse.Ingredients.Add(ingredientsToAdd);


                var state  = ctx.Entry(sandwishToUse).State;
                var state2 = ctx.Entry(ingredientsToAdd).State;
                ctx.SaveChanges();
            }

            return(true);
        }
Example #14
0
        public void WrongIngredientsOrder2()
        {
            var sandwich = new Sandwich();

            sandwich.Add(pork);
            Assert.AreEqual(sandwich.Meat, null);
        }
Example #15
0
        static void Main(string[] args)
        {
            var sandwich = new Sandwich(
                new WheatBread(),
                new CondimentList(
                    new List <Condiment> {
                new MayoCondiment(), new MustardCondiment()
            }
                    ),
                new IngredientList(
                    new List <Ingredient> {
                new LettuceIngredient(), new ChickenIngredient()
            }
                    ),
                new CondimentList(
                    new List <Condiment> {
                new MayoCondiment(), new MustardCondiment()
            }
                    ),
                new WheatBread()
                );

            sandwich.Interpret(new Context());
            Console.ReadKey();
        }
        public void SandwichTest()
        {
            var ing1 = new Ingredient {
                NameFrench = "Tartare de boeuf", NameEnglish = "Beef tartare", NameDutch = "Tartaar van Rundvlees", Allergene = false
            };
            var ing2 = new Ingredient {
                NameFrench = "cornichon", NameEnglish = "pickle", NameDutch = "Augurkje", Allergene = false
            };
            var ing3 = new Ingredient {
                NameFrench = "cacahuète", NameEnglish = "peanut", NameDutch = "Pinda", Allergene = true
            };

            List <Ingredient> ingredientList = new List <Ingredient> {
                ing1, ing2, ing3
            };                                                                          // instead of ingredientList.Add(ing1); ingredientList.Add(ing1);

            var san1 = new Sandwich {
                NameEnglish = "Sandwich English", NameFrench = "Sandiwch French", NameDutch = "Sandiwch Dutch", Ingredient = ingredientList
            };

            //Act
            string text = san1.GetIngredientList(Language.Dutch);

            //Assert
            Assert.AreEqual("Tartaar van Rundvlees, Augurkje, Pinda*", text);
        }
Example #17
0
        private void BtMake_Click(object sender, RoutedEventArgs e)
        {
            CustomDialog dialog = new CustomDialog();

            if (dialog.ShowDialog() == true)
            {
                if (dialog.DialogResult == true)
                {
                    Sandwich test = new Sandwich();
                    test.Bread   = dialog.BreadType;
                    test.Veggies = dialog.Veggies;

                    TblBread.Text = test.Bread;

                    string SelectedVeggies = null;


                    foreach (string veggies in test.Veggies)
                    {
                        if (veggies == "")
                        {
                            continue;
                        }
                        SelectedVeggies += veggies + ", ";
                    }
                    MessageBox.Show(SelectedVeggies);

                    TblVeggies.Text = SelectedVeggies;
                }
            }
        }
 public override void Update(Sandwich sandwich)
 {
     _sandwich      = sandwich;
     _observerState = _sandwich.GetDescription();
     Console.WriteLine("Observer {0}'s new state is {1}",
                       _name, _observerState);
 }
    public static IEnumerable <Sandwich <TSource> > Sandwich <TSource>(this IEnumerable <TSource> source)
    {
        var withExtras = source.AddFakeSlices();

        var sandwiches = withExtras
                         .Skip(1)
                         .Zip(withExtras, (curr, prev) => new
        {
            Current  = curr,
            Previous = prev
        })
                         .Zip(withExtras.Skip(2), (curr, next) => new
        {
            curr.Previous,
            curr.Current,
            Next = next
        });

        foreach (var item in sandwiches)
        {
            var sandwich = new Sandwich <TSource>()
            {
                Previous = item.Previous,
                Current  = item.Current,
                Next     = item.Next
            };

            yield return(sandwich);
        }
    }
    void Awake()
    {
        foodses    = new Foods[7];
        foodses[0] = new Sandwich(true, false, false, false, false);
        foodses[1] = new Sandwich(true, true, false, false, false);
        foodses[2] = new Sandwich(true, false, true, false, false);
        foodses[3] = new Sandwich(true, true, true, false, false);

        //////////////////////
        orders = new Order[4];
        //	for (int i = 0; i < orders.Length; i++) {

        orders[0] = new Order(foodses[0], true, false, false);
        orders[1] = new Order(foodses[1], true, false, false);
        orders[2] = new Order(foodses[2], true, false, false);
        orders[3] = new Order(foodses[3], true, false, false);
        //	}
        /////////////////////////////////////////////
        moshtaries = new Costumer[4];
        for (int i = 0; i < moshtaries.Length; i++)
        {
            moshtaries[i] = new Costumer(orders[i]);
        }
        ////////////////
    }
Example #21
0
        public static void Main(string[] args)
        {
            Sandwich sandwich = new Sandwich(true, true, true, false, false, true);

            Ingredients[] ingreds = new Ingredients[6];
            ingreds[0] = sandwich.bread;
        }
Example #22
0
        public IActionResult Edit(int id, [Bind("Id,Available,Description,Name,Price")] Sandwich sandwich)
        {
            if (id != sandwich.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var oldEntity = TenHourExecutionManager.context.ChangeTracker.Entries <Sandwich>().Select(x => x.Entity as Sandwich).AsQueryable().SingleOrDefault(m => m.Id == id);
                //dans le cas d'une entrée ajoutée et modifiée sans avoir encore été validée sur la bd, les modifications se font en dur (problème de référence des ids)
                if (TenHourExecutionManager.context.ChangeTracker.Entries().LastOrDefault().Context.Entry(oldEntity).State == EntityState.Added)
                {
                    oldEntity.Available   = sandwich.Available;
                    oldEntity.Description = sandwich.Description;
                    oldEntity.Name        = sandwich.Name;
                    oldEntity.Price       = sandwich.Price;
                }
                //dans le cas de la modification d'une entité déjà présente sur la bd, l'entité du contexte static est détachée et la nouvelle est ajoutée comme updated.
                else
                {
                    TenHourExecutionManager.context.Entry(oldEntity).State = EntityState.Detached;
                    TenHourExecutionManager.context.Entry(sandwich).State  = EntityState.Modified;
                }

                return(RedirectToAction("Index"));
            }
            return(View(sandwich));
        }
Example #23
0
        public async Task DelOrder()
        {
            try
            {
                Sandwich     order = SS.activeOrders.First(s => s.Value.UserId == Context.User.Id).Value;
                IUserMessage msg   = await ReplyAsync("Deleting order...");

                SS.activeOrders.Remove(order.Id);
                IGuild usr = await Context.Client.GetGuildAsync(SS.usrID);

                ITextChannel usrc = await usr.GetTextChannelAsync(SS.usrcID);

                await usrc.SendMessageAsync($"Order `{order.Id}`,`{order.Desc}` has been **REMOVED**.");

                SS.Save();
                await msg.ModifyAsync(x =>
                {
                    x.Content = "Successfully deleted order!";
                });
            }
            catch (Exception e)
            {
                await ReplyAsync("Failed to delete. Are you sure you have one?");
            }
        }
Example #24
0
        public bool AddSandwishInMenu(Sandwich sandwishToUse)
        {
            if (sandwishToUse == null)
            {
                throw new ArgumentNullException(nameof(sandwishToUse));
            }

            if (sandwishToUse.SandwichId != 0)
            {
                throw new Exception(nameof(sandwishToUse));
            }

            if (String.IsNullOrEmpty(sandwishToUse.Name) || String.IsNullOrWhiteSpace(sandwishToUse.Name))
            {
                throw new Exception(nameof(sandwishToUse));
            }

            using (var ctx = new SandwishContext())
            {
                if (ctx.Sandwiches.Any(x => x.Name == sandwishToUse.Name))
                {
                    throw new Exception(nameof(sandwishToUse));
                }
                ctx.Sandwiches.Add(sandwishToUse);
                ctx.SaveChanges();
            }

            return(true);
        }
 public void RemoveOrder(Sandwich o)
 {
     if (CurrentQueue.Contains(o))
     {
         CurrentQueue.Remove(o);
     }
 }
Example #26
0
        public ActionResult Create(Sandwich sandwich)
        {
            var adminRole = new AdminRole();

            adminRole.AddSandwishInMenu(sandwich);

            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Sandwich sandwich = db.Sandwiches.Find(id);

            db.Sandwiches.Remove(sandwich);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void JumpOrder(Sandwich o)
 {
     if (CurrentQueue.Contains(o))
     {
         CurrentQueue.Remove(o);
         CurrentQueue.AddFirst(o);
     }
 }
Example #29
0
        public void Cook1Sandwich()
        {
            MachineCommand[] commands = CreateCommands();

            Sandwich sandwich = machine.Cook(commands);

            _testContextInstance.WriteLine("sandwich ready");
        }
Example #30
0
 public Sandwich Post([FromBody] Sandwich newSandwich)
 {
     if (ModelState.IsValid)
     {
         return(db.AddSandwich(newSandwich));
     }
     return(null);
 }
Example #31
0
 private Sandwich HacerSandwich()//metodo de tipo Sandwich, que a su vez deriva de Comida.
 {
     Sandwich sandwich = new Sandwich();//se crea un objeto de la clase Sandwich.
     sandwich.Ingredientes = ListaDeIngredientes.panBimbo |//se manda llamar la propiedad Ingredientes que es de tipo ListaDeIngredientes(enum)
                           ListaDeIngredientes.lechuga |
                           ListaDeIngredientes.jitomate |
                           ListaDeIngredientes.jamon |
                           ListaDeIngredientes.cebolla;
     return sandwich;//regresa un objeto de tipo Sandwich, que a su vez, hereda de la clase Comida.
 }
        public static void Main(string[] args)
        {
            Console.WriteLine("Sandwich Shop");

            var typeSelected = PromptForSandwichType();
            temp = Activator.CreateInstance(types[typeSelected-1]) as Sandwich;
            Console.WriteLine();

            var addOnsSelected = PromptForAddOns();
            foreach (int index in addOnsSelected)
            {
                sandwich = Activator.CreateInstance(addOns[index-1], new object[] { temp }) as Sandwich;
                temp = sandwich;
            }
            Console.WriteLine();

            var sizeSelected = PromptForSize();
            sandwich = Activator.CreateInstance(sizes[sizeSelected-1], new object[] { temp }) as Sandwich;
            Console.WriteLine();

            Console.WriteLine("Price: ${0}", string.Format("{0:0.00}", sandwich.Price));
            Console.ReadLine();
        }
 public Cheese(Sandwich sandwich)
     : base(sandwich)
 {
     this.Description = "Cheese";
 }
Example #34
0
 public Tomato(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 0.35;
 }
Example #35
0
 public Cheese(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 0.50;
 }
Example #36
0
 public Regular(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 2.00;
 }
 protected SandwichDecorator(Sandwich sandwich)
 {
     this.Sandwich = sandwich;
 }
 public SauteedOnion(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 0.75;
 }
Example #39
0
 public Large(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 2.50;
 }
 public SandwichAddOn(Sandwich decoratedSandwich)
 {
     this.decoratedSandwich = decoratedSandwich;
 }
 public Corn(Sandwich sandwich)
     : base(sandwich)
 {
     this.Description = "Corn";
 }
Example #42
0
 public Avocado(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 0.25;
 }
Example #43
0
 public Bacon(Sandwich decoratedSandwich)
     : base(decoratedSandwich)
 {
     price = 1.00;
 }
 public Olives(Sandwich sandwich)
     : base(sandwich)
 {
     this.Description = "Olives";
 }
        private void updatePrice()
        {
            Type sandwichType = getSelectedSandwich();
            temp = Activator.CreateInstance(sandwichType) as Sandwich;

            List<Type> addOns = getSelectedAddOns();
            foreach (Type addOn in addOns)
            {
                sandwich = Activator.CreateInstance(addOn, new object[] { temp }) as Sandwich;
                temp = sandwich;
            }

            Type size = getSelectedSize();
            sandwich = Activator.CreateInstance(size, new object[] { temp }) as Sandwich;

            Price.Content = "Price: $" + string.Format("{0:0.00}", sandwich.Price);
        }