Ejemplo n.º 1
0
        public async Task<IHttpActionResult> PostDish(Dish dish)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Dishes.Add(dish);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DishExists(dish.Id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = dish.Id }, dish);
        }
Ejemplo n.º 2
0
        public ActionResult Create(string dishCategoryName, Dish dish, IList<Dish_Locale> locales)
        {
            var dishCategory = db.DishCategories.SingleOrDefault(dc => dc.Name.Equals(dishCategoryName, StringComparison.InvariantCultureIgnoreCase));

            if (dishCategory == null)
            {
                TempData["Result"] = Resource.RecordNotFound;
            }
            else
            {
                dish.DishCategory = dishCategory;

                foreach (var locale in locales)
                    locale.Dish = dish;

                if (ModelState.IsValid)
                {
                    db.Dishes.AddObject(dish);

                    db.SaveChanges();

                    TempData["Result"] = Resource.ChangesSaved;
                }
                else
                {
                    return Create();
                }
            }
            return RedirectToAction("Index", "DishCategory", new { dishCategoryName = dishCategoryName });
        }
        public Menu MakeMenu()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() {ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);

            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            menu = facade.MenuRepo().Add(menu);
            return menu;
        }
Ejemplo n.º 4
0
        public async Task<IHttpActionResult> PutDish(Guid id, Dish dish)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != dish.Id)
            {
                return BadRequest();
            }

            db.Entry(dish).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DishExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 5
0
        public void Dish_compare_ingredients_test()
        {
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };

            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = new List<Ingredient>() { ing, ing2 },
                Name = "dish1",
                Status = 0
            }; Dish dish2 = new Dish()
            {
                Description = "asd",
                Ingredients = new List<Ingredient>() { ing, ing2 },

                Name = "dish1",
                Status = 0
            };

            Assert.IsTrue(dish.Equals(dish2));
            dish.Ingredients.Add(new Ingredient() { Name = "changed", Price = 0 });

            Assert.IsFalse(dish.Equals(dish2));
            Assert.IsFalse(dish.Equals(null));
        }
        public void Dish_add_throws_exception_on_updated_ingredient_test()
        {
            Facade facade = new Facade();

            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };

            ing2 = facade.IngredientRepo().Add(ing2);

            ing2.Name = "Changed";
            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
        }
        public void Menu_add_throws_exception_on_updated_dish_test()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() { ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);
            dish1.Name = "changed";
            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            menu = facade.MenuRepo().Add(menu);
        }
        public TrainingSession RemoveDish(int id, Dish dish)
        {
            var training = this.trainings.GetById(id);
            training.Dishes.Remove(dish);
            this.trainings.Save();

            return training;
        }
Ejemplo n.º 9
0
        public ActionResult Create()
        {
            var dish = new Dish();

            foreach (var culture in SupportedCulture.GetList())
                dish.Dishes_Locale.Add(new Dish_Locale() { Culture = culture });

            return View(dish);
        }
Ejemplo n.º 10
0
        public void Dish_data_annotations_test()
        {
            Dish dish = new Dish();

            var context = new ValidationContext(dish, serviceProvider: null, items: null);
            var results = new List<ValidationResult>();
            var isValid = Validator.TryValidateObject(dish, context, results, true);

            Assert.IsTrue(results.Any(x => x.ErrorMessage == "Name is required"));
        }
        public bool CreateNewDish(string dishName, int dishNumber, decimal dishPrice, int restaurantMenuID)
        {
            Dish dish = new Dish();
            dish.Name = dishName;
            dish.Price = dishPrice;
            dish.Number = dishNumber;
            dish.RestaurantMenuID = restaurantMenuID;
            Response<Dish> response = dish.Create();

            return response.Success;
        }
Ejemplo n.º 12
0
        public PreparationViewModel()
        {
            Starter = new Dish("lol", DishType.Starter, "meatballs.jpg", "ok");
            Starter.Ingredients.Add(new Ingredient("shit", 200, "oz", 1.4));

            Main = new Dish("lol", DishType.Main, "meatballs.jpg", "ok");
            Main.Ingredients.Add(new Ingredient("shit", 200, "oz", 1.4));

            Dessert = new Dish("lol", DishType.Dessert, "meatballs.jpg", "ok");
            Dessert.Ingredients.Add(new Ingredient("shit", 200, "oz", 1.4));
        }
Ejemplo n.º 13
0
        public DishViewModel(Dish dish)
        {
            if (dish != null)
            {
                Group = dish.DishGroup.Name;
                Name = dish.Name;
                Price = dish.Price;

                Id = dish.Id;
            }
        }
 public void Dish_add_using_new_ingredient_throws_exception_test()
 {
     Facade facade = new Facade();
     Dish dish = new Dish()
     {
         Description = "asd",
         Name = "asd",
         Status = 1,
         Ingredients = new List<Ingredient>() { new Ingredient() { Name = "123", Price = 123 } }
     };
     facade.DishRepo().Add(dish);
 }
Ejemplo n.º 15
0
 public void DishCanAddCellWithUserInputParseMethod()
 {
     Dish dish = new Dish();
     string userInput = "2,2";
     Dish expectedDish = new Dish();
     expectedDish.AddCell(2, 2);
     dish.AddCell(Parse.Convert(userInput));
     Assert.IsNotNull(dish);
     Assert.AreEqual(1, dish.Count);
     Assert.AreEqual(expectedDish[0].xcoord, dish[0].xcoord);
     Assert.AreEqual(expectedDish[0].ycoord, dish[0].ycoord);
 }
Ejemplo n.º 16
0
        public Dish GetByName(string name)
        {
            // TODO: Check creation
            var dish = this.dishes.All().FirstOrDefault(x => x.Name == name);
            if (dish != null)
            {
                return dish;
            }

            dish = new Dish { Name = name };
            this.dishes.Add(dish);
            this.dishes.Save();
            return dish;
        }
Ejemplo n.º 17
0
        public ActionResult Create(Dish dish)
        {
            try
            {
                cm.Dishes.Add(dish);
                cm.SaveChanges();
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public Party MakeParty()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() { ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);

            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            Menu menu2 = new Menu() { Dishes = new List<Dish> { dish1, dish2 }, Name = "menu2" };
            menu = facade.MenuRepo().Add(menu);
            menu2 = facade.MenuRepo().Add(menu2);

            Address address = new Address() { Country = "Denmark", StreetAddress = "Møbelvej 3", ZipCode = "6800" };
            Address address2 = new Address() { Country = "Denmark", StreetAddress = "gyvelunden 3", ZipCode = "6800" };
            address = facade.AddressRepo().Add(address);
            address2 = facade.AddressRepo().Add(address2);

            Customer cus = new Customer(){Address = address, Email = "*****@*****.**",FirstName = "Jonas",LastName = "Olesen",PhoneNumber = "22342312"};
            cus = facade.CustomerRepo().Add(cus);

            Party party = new Party()
            {
                Address = address2,
                Customer = cus,
                CreationDate = DateTime.Now.AddYears(-2),
                Description = "Description",
                FestNummer = "1",
                Menus = new List<Menu>() { menu, menu2 },
                UseDate = DateTime.Now.AddMonths(-1)
            };
            party = facade.PartyRepo().Add(party);
            return party;
        }
Ejemplo n.º 19
0
        public void DishEnsureNextGenerationAddsAndDeletesAppropriateCells()
        {
            Dish expectedDish = new Dish();
            expectedDish.AddCell(0, 0);
            expectedDish.AddCell(1, 0);
            expectedDish.AddCell(-1, 0);

            Dish dish = new Dish();
            dish.AddCell(0, 0);
            dish.AddCell(0, 1);
            dish.AddCell(0, -1);

            dish.NextGeneration();

            Assert.AreEqual(expectedDish.ToString(), dish.ToString());
        }
Ejemplo n.º 20
0
        public void Menu_compare_dishes_test()
        {
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };

            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = new List<Ingredient>() { ing, ing2 },
                Name = "dish1",
                Status = 0
            }; Dish dish2 = new Dish()
            {
                Description = "asd",
                Ingredients = new List<Ingredient>() { ing, ing2 },

                Name = "dish1",
                Status = 0
            };
            Menu menu1 = new Menu()
            {
                Dishes = new List<Dish>() { dish, dish2 },
                Name = "menu1"
            };
            Menu menu2 = new Menu()
            {
                Dishes = new List<Dish>() { dish, dish2 },
                Name = "menu1"
            };

            Assert.IsTrue(menu1.Equals(menu2));
            menu1.Dishes.Add(new Dish() { Name = "changed" });

            Assert.IsFalse(menu1.Equals(menu2));
            Assert.IsFalse(menu1.Equals(null));
        }
Ejemplo n.º 21
0
    private static void ChooseOptimalDishes(Dish[] dishArray, int capacity, int numberOfDishes)
    {
        long[,] costMatrix = new long[numberOfDishes, capacity + 1];
        bool[,] isTaken = new bool[numberOfDishes, capacity + 1];
        for (int i = 0; i < capacity + 1; i++)
        {
            if (dishArray[0].Weight <= i)
            {
                costMatrix[0, i] = dishArray[0].Value;
                isTaken[0, i] = true;
            }
        }

        for (int i = 1; i < numberOfDishes; i++)
        {
            for (int j = 0; j < capacity + 1; j++)
            {
                costMatrix[i, j] = costMatrix[i - 1, j];
                int remainingCapacity = j - dishArray[i].Weight;
                if (remainingCapacity >= 0
                    && costMatrix[i - 1, remainingCapacity] + dishArray[i].Value > costMatrix[i - 1, j])
                {
                    costMatrix[i, j] = costMatrix[i - 1, remainingCapacity] + dishArray[i].Value;
                    isTaken[i, j] = true;
                }
            }
        }

        LinkedList<Dish> takenItems = new LinkedList<Dish>();
        int rowIndex = numberOfDishes - 1;
        int collumnIndex = capacity;

        Console.WriteLine(costMatrix[rowIndex, collumnIndex]);
        while (rowIndex >= 0)
        {
            if (isTaken[rowIndex, collumnIndex])
            {
                Console.WriteLine(dishArray[rowIndex].Name);
                //takenItems.AddFirst(dishArray[rowIndex]);
                collumnIndex -= dishArray[rowIndex].Weight;
            }
            rowIndex--;
        }
    }
Ejemplo n.º 22
0
        public ActionResult AddDish(string name, string description, double price, double timeToCook, int specialtyId,
            int dishTypeId)
        {
            RestaurantService restaurantService = new RestaurantService();
            MenuService menuService = new MenuService();
            Specialty specialty = menuService.GetSpecialty(specialtyId);

            Dish dish = new Dish
                            {
                                Name = name,
                                Description = description,
                                Price = price,
                                TimeToCook = timeToCook,
                                Specialty = specialty,
                                DishTypeId = dishTypeId
                            };

            restaurantService.AddDish(dish);

            return RedirectToAction("ListDishes");
        }
Ejemplo n.º 23
0
        public IActionResult Show(int DishId)
        {
            Dish oneDish = dbContext.Dishes.FirstOrDefault(dish => dish.DishId == DishId);

            return(View("Show", oneDish));
        }
Ejemplo n.º 24
0
 public DishModelDto GetDishModelDto(Dish dish, int menufordayid)
 {
     return(_repository.GetDishModelDto(dish, menufordayid));
 }
Ejemplo n.º 25
0
        public IActionResult Details(int myDishID)
        {
            Dish OneDish = dbContext.Dishes.FirstOrDefault(result => result.DishID == myDishID);

            return(View("Details", OneDish));
        }
Ejemplo n.º 26
0
 public EatAppleSmp()
 {
     Thread th_mother, th_father, th_young, th_middle, th_old;
     Dish dish = new Dish( this, 30 );
     Productor mother = new Productor( "mother", dish );
     Productor father = new Productor( "father", dish );
     Consumer old = new Consumer( "old", dish, 1000 );
     Consumer middle = new Consumer( "middle", dish, 1200 );
     Consumer young = new Consumer( "young", dish, 1500 );
     th_mother = new Thread( new ThreadStart( mother.run ) );
     th_father = new Thread( new ThreadStart( father.run ) );
     th_old = new Thread( new ThreadStart( old.run ) );
     th_middle = new Thread( new ThreadStart( middle.run ) );
     th_young = new Thread( new ThreadStart( young.run ) );
     th_mother.Priority = System.Threading.ThreadPriority.Highest;
     th_father.Priority = System.Threading.ThreadPriority.Normal;
     th_old.Priority = System.Threading.ThreadPriority.Lowest;
     th_middle.Priority = System.Threading.ThreadPriority.Normal;
     th_young.Priority = System.Threading.ThreadPriority.Highest;
     th_mother.Start();
     th_father.Start();
     th_old.Start();
     th_middle.Start();
     th_young.Start();
 }
Ejemplo n.º 27
0
 public void updateDish(Dish dish)
 {
     db.Updateable(dish).ExecuteCommand();
 }
Ejemplo n.º 28
0
        public async Task <BaseResponse> CreateSample()
        {
            BaseResponse result = new BaseResponse();

            List <Dish> dishes = new List <Dish>();

            Dish peperoni = new Dish
            {
                Title          = "Peperoni".ToTitleForStore(),
                AvailableCount = 60,
                Category       = "Main Course".ToTitleForStore(),
                SubCategory    = "Pizza".ToTitleForStore(),
                EstimatedTime  = 40,
                IsDiactive     = false,
                Price          = 10,
                MealType       = new List <MealType>(),
                Days           = new List <Day>(),
                Ingredients    = new Dictionary <string, string>(),
            };

            peperoni.MealType.Add(MealType.Breakfast);
            peperoni.MealType.Add(MealType.Lunch);
            peperoni.MealType.Add(MealType.Dinner);

            peperoni.Days.Add(Day.Monday);

            peperoni.Ingredients.Add(new KeyValuePair <string, string>("Sausage", "100g"));
            peperoni.Ingredients.Add(new KeyValuePair <string, string>("Cheese", "150g"));

            Dish mix = new Dish
            {
                Title          = "Milano",
                AvailableCount = 60,
                Category       = "Main course".ToTitleForStore(),
                SubCategory    = "Pizza".ToTitleForStore(),
                EstimatedTime  = 30,
                IsDiactive     = false,
                Price          = 10,
                MealType       = new List <MealType>(),
                Days           = new List <Day>(),
                Ingredients    = new Dictionary <string, string>(),
            };

            mix.MealType.Add(MealType.All);

            mix.Days.Add(Day.AllDayOfWeek);

            mix.Ingredients.Add(new KeyValuePair <string, string>("Sausage", "100g"));
            mix.Ingredients.Add(new KeyValuePair <string, string>("Cheese", "150g"));

            Dish Cheeseburger = new Dish
            {
                Title          = "Cheese Burger",
                AvailableCount = 60,
                Category       = " main course".ToTitleForStore(),
                SubCategory    = "Hamburger".ToTitleForStore(),
                EstimatedTime  = 30,
                IsDiactive     = false,
                Price          = 10,
                MealType       = new List <MealType>(),
                Days           = new List <Day>(),
                Ingredients    = new Dictionary <string, string>(),
            };

            Cheeseburger.MealType.Add(MealType.Lunch);
            Cheeseburger.MealType.Add(MealType.Dinner);

            Cheeseburger.Days.Add(Day.AllDayOfWeek);

            Cheeseburger.Ingredients.Add(new KeyValuePair <string, string>("Hamburger", "100g"));
            Cheeseburger.Ingredients.Add(new KeyValuePair <string, string>("Lettuce", "150g"));

            Dish doubleBurger = new Dish
            {
                Title          = "Double Burger".ToTitleForStore(),
                AvailableCount = 60,
                Category       = "Main Course".ToTitleForStore(),
                SubCategory    = "Hamburger".ToTitleForStore(),
                EstimatedTime  = 30,
                IsDiactive     = false,
                Price          = 10,
                MealType       = new List <MealType>(),
                Days           = new List <Day>(),
                Ingredients    = new Dictionary <string, string>(),
            };

            doubleBurger.MealType.Add(MealType.Lunch);
            doubleBurger.MealType.Add(MealType.Dinner);

            doubleBurger.Days.Add(Day.AllDayOfWeek);

            doubleBurger.Ingredients.Add(new KeyValuePair <string, string>("Hamburger", "300g"));
            doubleBurger.Ingredients.Add(new KeyValuePair <string, string>("Cheese", "150g"));

            Dish ItalianIceCream = new Dish
            {
                Title          = "   italian Ice Cream".ToTitleForStore(),
                AvailableCount = 60,
                Category       = "Dessert   ".ToTitleForStore(),
                SubCategory    = "Ice Cream".ToTitleForStore(),
                EstimatedTime  = 30,
                IsDiactive     = false,
                Price          = 10,
                MealType       = new List <MealType>(),
                Days           = new List <Day>(),
                Ingredients    = new Dictionary <string, string>(),
            };

            ItalianIceCream.MealType.Add(MealType.Lunch);
            ItalianIceCream.MealType.Add(MealType.Dinner);

            ItalianIceCream.Days.Add(Day.AllDayOfWeek);

            Dish Salad = new Dish
            {
                Title          = "   salad sezar".ToTitleForStore(),
                AvailableCount = 60,
                Category       = "Starter   ".ToTitleForStore(),
                SubCategory    = "Salad".ToTitleForStore(),
                EstimatedTime  = 30,
                IsDiactive     = false,
                Price          = 10,
                MealType       = new List <MealType>(),
                Days           = new List <Day>(),
                Ingredients    = new Dictionary <string, string>(),
            };

            Salad.MealType.Add(MealType.Lunch);
            Salad.MealType.Add(MealType.Dinner);

            Salad.Days.Add(Day.AllDayOfWeek);



            dishes.Add(peperoni);
            dishes.Add(mix);
            dishes.Add(Cheeseburger);
            dishes.Add(doubleBurger);
            dishes.Add(ItalianIceCream);
            dishes.Add(Salad);

            try
            {
                await _dishRepository.Create(dishes);
            }
            catch (TimeoutException)
            {
                result.SetError(ErrorMessage.TimeoutError);
            }
            catch (Exception ex)
            {
                result.SetError(ex);
            }

            return(result);
        }
Ejemplo n.º 29
0
 public Consumer(string name, Dish dish, int timelong)
 {
     this.name = name;
     this.dish = dish;
     this.timelong = timelong;
 }
Ejemplo n.º 30
0
        public IActionResult Details(int id)
        {
            Dish selectedDish = _context.Dishes.FirstOrDefault(Dish => Dish.id == id);

            return(View("details", selectedDish));
        }
Ejemplo n.º 31
0
        public IActionResult Edit(int DishId)
        {
            Dish RetrievedDish = dbContext.Dishes.FirstOrDefault(Dish => Dish.DishId == DishId);

            return(View("Update", RetrievedDish));
        }
Ejemplo n.º 32
0
 public IActionResult InsertDish(Dish newDish)
 {
     dbContext.Add(newDish);
     dbContext.SaveChanges();
     return(RedirectToAction("Dishes"));
 }
 public void Menu_update_updates_added_child_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     Dish dish = new Dish() { Description = "asd", Name = "asd", Status = 2 };
     dish = facade.DishRepo().Add(dish);
     menu.Dishes.Add(dish);
     facade.MenuRepo().Update(menu);
     Assert.IsTrue(facade.MenuRepo().Get(menu.Id).Dishes.Any(x => x.Id == dish.Id));
 }
 public void Menu_update_throws_exception_on_new_dish_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     Dish dish = new Dish() { Description = "asd", Name = "asd", Status = 2 };
     menu.Dishes.Add(dish);
     facade.MenuRepo().Update(menu);
 }
Ejemplo n.º 35
0
 public Dish UpdateDish(Dish dish)
 {
     return(dish);
 }
Ejemplo n.º 36
0
 public Dish CreateDish(Dish dish)
 {
     dish.Id = 99;
     return(dish);
 }
Ejemplo n.º 37
0
        public IActionResult Info(int dishId)
        {
            Dish ClickedDish = dbContext.Dish.FirstOrDefault(d => d.DishId == dishId);

            return(View("Info", ClickedDish));
        }
Ejemplo n.º 38
0
 public Dish AddDish(Dish dish)
 {
     return(DishDB.AddDish(dish));
 }
Ejemplo n.º 39
0
 private void SetData(Dish dish)
 {
     if (dish != null)
     {
         Name = dish.Name;
         Price = dish.Price;
         Group = dish.DishGroup.Name;
         SelecteDishGroup = dish.DishGroup;
     }
     _dish = dish;
 }
Ejemplo n.º 40
0
 public int UpdateDish(Dish dish)
 {
     return(DishDB.UpdateDish(dish));
 }
Ejemplo n.º 41
0
        public IActionResult Edit(int id)
        {
            Dish EditDish = dbContext.Dish.FirstOrDefault(dish => dish.DishId == id);

            return(View(EditDish));
        }
Ejemplo n.º 42
0
        public Dish CookOrder(Dish dish)
        {
            Dish preparedDish = dish;

            return(preparedDish);
        }
Ejemplo n.º 43
0
 public Productor(string name, Dish dish)
 {
     this.name = name;
     this.dish = dish;
 }
Ejemplo n.º 44
0
        public static void FillDishMenu()
        {
            /// Voor Gerechten ///
            Dish BreadPlate    = new Dish(1001, "Bread Plate", DishTypes.Vega, 5.50, "Warm bread with garlic butter, avioli and tapenade");
            Dish OnionSoup     = new Dish(1002, "French Onion Soup", DishTypes.Vega, 6.75, "Homemade, gratinated with cheese");
            Dish SupremeNacho  = new Dish(1003, "Supreme Nacho's", DishTypes.Vega, 10.75, "From the oven with jalapeno's, cheddar, tomato, onion, crême fraiche, homemade guacemole and spicy salsa");
            Dish AvocadoRoyale = new Dish(1004, "Avocado Royale", DishTypes.Fish, 10.90, "Shrimp cocktail from Dutch shrimps, coktailsauce and 1 / 2 avocado");
            Dish SmokeySalmon  = new Dish(1005, "Smokey Salmon", DishTypes.Fish, 11.50, "Norwegian smoked salmon, spiced cheese and bread");
            Dish BuffaloWings  = new Dish(1006, "Buffalo Wings", DishTypes.Meat, 12.50, "Chicken wings marinated in a smokey barbecue sauce");
            Dish Carpaccio     = new Dish(1007, "Carpaccio", DishTypes.Meat, 11.50, "Dressing of truffle mayonaise, lettuce, sundried tomato, parmesan and pine nuts");
            Dish Chorizo       = new Dish(1008, "Chorizo", DishTypes.Meat, 9.90, "Two spicy chorizo sausages with garlic sauce");

            /// Vlees Gerechten ///
            Dish Entrecote         = new Dish(2001, "Entrecote", DishTypes.Meat, 25.00, "Sirloin 300gr with a characteristic grease rim");
            Dish HalfChicken       = new Dish(2002, "1/2 Chicken", DishTypes.Meat, 12.00, "Grilled in the oven with the flavours: Spicy | Ketjap | BBQ");
            Dish Chicken           = new Dish(2003, "1/1 Chicken", DishTypes.Meat, 19.50, "Grilled in the oven with the flavours: Spicy | Ketjap | BBQ");
            Dish MixedGrill        = new Dish(2004, "Mixed Grill", DishTypes.Meat, 25.00, "Entrecote, spicy ribs, chicken fillet, chorizo and a rack of lamb");
            Dish Tenderloin        = new Dish(2005, "Tenderloin", DishTypes.Meat, 29.50, "Tournedos 300gr, the most tender part of the bovine");
            Dish Ribeye            = new Dish(2006, "Ribeye", DishTypes.Meat, 26.00, "Beef 300gr from the ribs, grained in fat");
            Dish SatansRibs        = new Dish(2007, "Satans Ribs", DishTypes.Meat, 17.50, "Made in the charcoal grill with the flavours: Spicy | Ketjap | BBQ | Sweet");
            Dish TenderloinSkewer  = new Dish(2008, "Tenderloin Skewer", DishTypes.Meat, 23.50, "With home made saté sauce");
            Dish ChickenSkewer     = new Dish(2009, "Chicken Skewer", DishTypes.Meat, 16.00, "With home made saté sauce");
            Dish SilenceOfTheLambs = new Dish(2010, "Silence of the Lambs", DishTypes.Meat, 23.50, "Rack of lamb 300gr from New-Zealand");
            Dish TBone             = new Dish(2011, "T-Bone", DishTypes.Meat, 31.50, "T-Bone steak 600gr, for the real carnivores");
            Dish RoyaleWithCheese  = new Dish(2012, "Royale with Cheese", DishTypes.Meat, 13.50, "200gr Black angus burger with cheddar, lettuce, tomato, pickles and crispy bacon");

            /// Vis Gerechten ///
            Dish AtlanticSalmon = new Dish(2013, "Atlantic Salmon", DishTypes.Fish, 19.00, "Salmon fillet out of the charcoal grill");
            Dish Gamba          = new Dish(2014, "Gamba's", DishTypes.Fish, 20.50, "Gamba's out of the charcoal grill with garlic sauce");
            Dish MixedFishGrill = new Dish(2015, "Mixed Fish Grill", DishTypes.Fish, 25.00, "Gamba's, salmon fillet, tuna steak and Norwegian smoked salmon");
            Dish OceanKing      = new Dish(2016, "Ocean King", DishTypes.Fish, 19.00, "Tuna steak out of the charcoal grill");

            /// Vegetarische Gerechten ///
            Dish GreenWrap = new Dish(2017, "Green Wrap", DishTypes.Vega, 14.00, "Baked vegetables and cheddar cheese in a tortilla wrap");
            Dish Ravioli   = new Dish(2018, "Ravioli Ricotta Spinach", DishTypes.Vega, 13.00, "Ravioli filled with ricotta cheese, spinach and pesto-cream sauce");

            /// Na Gerechten ///
            Dish ChocolateBrownie    = new Dish(3001, "Pure Chocolate Brownie", DishTypes.Vega, 8.50, "With passion fruit sorbet and salted caramel");
            Dish CheeseBoard         = new Dish(3002, "Cheese Board", DishTypes.Vega, 8.50, "Varied cheeseboard with 3 kinds of cheese, fruit loaf and homemade chutney");
            Dish IceFondue           = new Dish(3003, "Ice Fondue", DishTypes.Vega, 19.00, "With pineapple and banana, sugar loaf, marshmellows, vanilla mascarpone cream, chocolate sauce and nuts");
            Dish DameBlanche         = new Dish(3004, "Dame Blanche", DishTypes.Vega, 6.50, "3 scoops of vanilla ice cream with hot chocolate sauce");
            Dish ChildrenIceCream    = new Dish(3005, "Children's Ice Cream", DishTypes.Vega, 4.00, "2 scoops of vanilla ice cream with decoration and a surprise");
            Dish CheesecakeMilkshake = new Dish(3006, "Cheesecake & Milkshake", DishTypes.Vega, 8.50, "New York style cheesecake with curd and a homemade milkshake");
            Dish CoffeeApplepie      = new Dish(3007, "Coffee with Applepie", DishTypes.Vega, 6.50, "A cup of coffee with homemade applepie");


            /// Frisdranken ///
            Dish Cola       = new Dish(4001, "Cola", DishTypes.Drink, 2.50, "Regular/Light/Zero");
            Dish Sprite     = new Dish(4002, "Sprite", DishTypes.Drink, 2.20, "");
            Dish Fanta      = new Dish(4003, "Fanta", DishTypes.Drink, 2.20, "");
            Dish Cassis     = new Dish(4004, "Cassis", DishTypes.Drink, 2.20, "");
            Dish IceTea     = new Dish(4005, "Ice Tea", DishTypes.Drink, 2.20, "Peach/Lemon");
            Dish JusdOrange = new Dish(4006, "Jus d'Orange", DishTypes.Drink, 2.80, "");
            Dish Water      = new Dish(4007, "Water", DishTypes.Drink, 1.50, "");
            Dish Tea        = new Dish(4008, "Tea", DishTypes.Drink, 2.20, "Many different flavours");

            /// Koffie ///
            Dish Black          = new Dish(5001, "Black Coffee", DishTypes.Drink, 2.30, "");
            Dish Cappuccino     = new Dish(5002, "Cappuccino", DishTypes.Drink, 3.00, "");
            Dish Espresso       = new Dish(5003, "Espresso", DishTypes.Drink, 2.75, "");
            Dish DoubleEspresso = new Dish(5004, "Double Espresso", DishTypes.Drink, 4.25, "");
            Dish CaffeLatte     = new Dish(5005, "Caffé Latte", DishTypes.Drink, 3.75, "");
            Dish LatteMacchiato = new Dish(5006, "Latte Macchiato", DishTypes.Drink, 3.75, "");
            Dish IrishCoffee    = new Dish(5007, "Irish Coffee", DishTypes.Drink, 6.95, "");
            Dish SpanishCoffee  = new Dish(5008, "Spanish Coffee", DishTypes.Drink, 6.95, "");
            Dish ItalianCoffee  = new Dish(5009, "Italian Coffee", DishTypes.Drink, 6.95, "");
            Dish FrenchCoffee   = new Dish(5010, "French Coffee", DishTypes.Drink, 6.95, "");
            Dish BaileysCoffee  = new Dish(5011, "Baileys Coffee", DishTypes.Drink, 6.95, "");

            /// Alcoholische Dranken ///
            Dish RedWine               = new Dish(6001, "Red Wine", DishTypes.Drink, 2.60, "");
            Dish WhiteWine             = new Dish(6002, "White Wine", DishTypes.Drink, 2.50, "");
            Dish RoseWine              = new Dish(6003, "Rosé Wine", DishTypes.Drink, 2.30, "");
            Dish GrolschAmsterdamSmall = new Dish(6004, "Grolsch Amsterdammer 0,25L", DishTypes.Drink, 2.75, "");
            Dish GrolschAmsterdam      = new Dish(6005, "Grolsch Amsterdammer 0,5L", DishTypes.Drink, 5.50, "");
            Dish GrolschWeizenSmall    = new Dish(6006, "Grolsch Weizen 0.3L", DishTypes.Drink, 4.75, "");
            Dish GrolschWeizen         = new Dish(6007, "Grolsch Weizen 0.5L", DishTypes.Drink, 7.85, "");
            Dish GrimmbergenBlond      = new Dish(6008, "Grimmbergen Blond", DishTypes.Drink, 4.35, "");
            Dish GrimmbergenDouble     = new Dish(6009, "Grimmbergen Double", DishTypes.Drink, 4.35, "");
            Dish Guiness               = new Dish(6010, "Guiness", DishTypes.Drink, 4.55, "");
            Dish HertogJan             = new Dish(6011, "Hertog Jan", DishTypes.Drink, 3.40, "");
            Dish Heineken              = new Dish(6012, "Heineken", DishTypes.Drink, 3.50, "");
            Dish Jupiler               = new Dish(6013, "Jupiler", DishTypes.Drink, 3.40, "");
            Dish Kornuit               = new Dish(6014, "Kornuit", DishTypes.Drink, 2.75, "");

            /// Sterke Drank ///
            Dish Rum          = new Dish(7001, "Rum", DishTypes.Drink, 6.00, "");
            Dish Vodka        = new Dish(7002, "Vodka", DishTypes.Drink, 5.50, "");
            Dish Bacardi      = new Dish(7003, "Bacardi", DishTypes.Drink, 5.50, "");
            Dish Whiskey      = new Dish(7004, "Whiskey", DishTypes.Drink, 5.50, "");
            Dish Ouzo         = new Dish(7005, "Ouzo", DishTypes.Drink, 4.25, "");
            Dish Safari       = new Dish(7006, "Safari", DishTypes.Drink, 3.85, "");
            Dish Malibu       = new Dish(7007, "Malibu", DishTypes.Drink, 3.85, "");
            Dish PinaColada   = new Dish(7008, "Pina Colada", DishTypes.Drink, 3.85, "");
            Dish Amaretto     = new Dish(7009, "Amaretto di Saronno", DishTypes.Drink, 4.25, "");
            Dish Baileys      = new Dish(7010, "Baileys", DishTypes.Drink, 4.25, "");
            Dish Sambuca      = new Dish(7011, "Sambuca", DishTypes.Drink, 3.85, "");
            Dish TiaMaria     = new Dish(7012, "Tia Maria", DishTypes.Drink, 4.25, "");
            Dish Boswandeling = new Dish(7013, "Boswandeling", DishTypes.Drink, 3.85, "");
            Dish Dropshot     = new Dish(7014, "Dropshot", DishTypes.Drink, 3.85, "");
            Dish Blueberry    = new Dish(7015, "Blueberry", DishTypes.Drink, 3.85, "");
            Dish Licor43      = new Dish(7016, "Licor 43", DishTypes.Drink, 4.25, "");
        }
Ejemplo n.º 45
0
 public void addDish(Dish dish)
 {
     db.Saveable(dish).ExecuteCommand();
 }
Ejemplo n.º 46
0
        public IActionResult singleDish(int dishId)
        {
            Dish singleDish = db.Dishes.FirstOrDefault(d => d.DishId == dishId);

            return(View("SingleDish", singleDish));
        }
Ejemplo n.º 47
0
 public void RemoveLine(Dish dish)
 {
     itemCollection.RemoveAll(d => d.Dish.DishID == dish.DishID);
 }
Ejemplo n.º 48
0
        public IActionResult Edit(int dishId)
        {
            Dish dishToEdit = db.Dishes.FirstOrDefault(d => d.DishId == dishId);

            return(View("Edit", dishToEdit));
        }
Ejemplo n.º 49
0
        public ActionResult Report(DetailItemizedSalesAnalysisModifiersviewModels model)
        {
            {
                try
                {
                    var             _lstCateChecked    = new List <RFilterCategoryModel>();
                    List <Modifier> ListModifierChoose = new List <Modifier>();

                    model.FilterType = (int)Commons.EFilterType.OnDay;
                    if (model.EndTime.Hours == 0 && model.EndTime.Minutes == 0)
                    {
                        model.EndTime = new TimeSpan(23, 59, 59);
                        if (model.StartTime.Hours == 0 && model.StartTime.Minutes == 0)
                        {
                            model.FilterType = (int)Commons.EFilterType.None;
                        }
                    }
                    else if (model.StartTime > model.EndTime)
                    {
                        model.FilterType = (int)Commons.EFilterType.Days;
                    }

                    DateTime dFrom = new DateTime(model.FromDate.Year, model.FromDate.Month, model.FromDate.Day, model.StartTime.Hours, model.StartTime.Minutes, 0)
                    , dTo          = new DateTime(model.ToDate.Year, model.ToDate.Month, model.ToDate.Day, model.EndTime.Hours, model.EndTime.Minutes, 0);
                    if (dFrom >= dTo)
                    {
                        ModelState.AddModelError("FromDate", CurrentUser.GetLanguageTextFromKey("From Date must be less than To Date."));
                    }
                    else
                    {
                        dTo = dTo.AddSeconds(59);
                    }

                    if (model.Type == Commons.TypeCompanySelected) //Company
                    {
                        if (model.ListCompanys == null)
                        {
                            ModelState.AddModelError("ListCompanys", CurrentUser.GetLanguageTextFromKey("Please choose company."));
                        }
                    }
                    else //Store
                    {
                        if (model.ListStores == null)
                        {
                            ModelState.AddModelError("ListStores", CurrentUser.GetLanguageTextFromKey("Please choose store."));
                        }
                    }

                    if (model.ListStoreCate != null)
                    {
                        model.ListCategories.AddRange(model.ListStoreCate.SelectMany(ss => ss.ListCategoriesSel).ToList());
                    }

                    //// Get list categories
                    if (model.ListCategories != null && model.ListCategories.Any())
                    {
                        _categoriesFactory.GetCategoryCheck_V1(ref _lstCateChecked, model.ListCategories);
                    }
                    else
                    {
                        var listCategories = GetListCategories(model.Type == 1 ? model.ListCompanys : model.ListStores, model.Type);
                        _categoriesFactory.GetCategoryCheck_V1(ref _lstCateChecked, listCategories, true);
                    }

                    if (model.ListStoreModifier != null)
                    {
                        ListModifierChoose = new List <Modifier>();
                        Modifier obj = null;
                        model.ListStoreModifier.ForEach(x =>
                        {
                            x.ListModifierSel = x.ListModifierSel.Where(y => y.Checked == true).ToList();
                            x.ListModifierSel.ForEach(z =>
                            {
                                obj              = new Modifier();
                                obj.ModifierId   = z.Id;
                                obj.ModifierName = z.Name;
                                obj.StoreId      = z.StoreId;
                                ListModifierChoose.Add(obj);
                            });
                        });
                    }

                    if (_lstCateChecked == null)
                    {
                        _lstCateChecked = new List <RFilterCategoryModel>();
                    }

                    if (ListModifierChoose == null)
                    {
                        ListModifierChoose = new List <Modifier>();
                    }

                    if (!ModelState.IsValid)
                    {
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        return(View("Index", model));
                    }
                    var _lstCateCheckedId = _lstCateChecked.Select(ss => ss.Id).ToList();
                    // Get list store selected
                    var _lstStoreCate = _lstCateChecked.Select(ss => ss.StoreId).Distinct().ToList();

                    model.FromDate       = new DateTime(model.FromDate.Year, model.FromDate.Month, model.FromDate.Day, 0, 0, 0);
                    model.ToDate         = new DateTime(model.ToDate.Year, model.ToDate.Month, model.ToDate.Day, 23, 59, 59);
                    model.FromDateFilter = dFrom;
                    model.ToDateFilter   = dTo;

                    ////create datat to test=====================================================
                    ///list store => list category => list dish
                    CategoryOnStore        CategoryOnStore          = null;
                    List <CategoryOnStore> ListCatgoryOnstoreChoose = new List <CategoryOnStore>();
                    CategoryOfDish         categoryOfDish           = null;
                    List <CategoryOfDish>  lstCategoryOfDish        = new List <CategoryOfDish>();
                    Dish                  _dish              = null;
                    List <Dish>           ListDish           = new List <Dish>();
                    List <ModifierOnDish> ListModifierOnDish = new List <ModifierOnDish>();
                    ModifierOnDish        modifieronDish     = null;
                    //List<Dish> LstDish = new List<Dish>();

                    for (int k = 0; k < 4; k++)
                    {
                        modifieronDish              = new ModifierOnDish();
                        modifieronDish.ModifierId   = "ModifierNameId" + k;
                        modifieronDish.ModifierName = "ModifierName" + k;
                        modifieronDish.DishAmount   = 9.9884;
                        modifieronDish.DishQuantity = 5.70;
                        ListModifierOnDish.Add(modifieronDish);
                    }
                    for (int z = 0; z < 2; z++)
                    {
                        _dish          = new Dish();
                        _dish.DishId   = "DishId" + z;
                        _dish.DishName = "DishName" + z;
                        _dish.ListModifierOnDish.AddRange(ListModifierOnDish);
                        ListDish.Add(_dish);
                    }
                    for (int j = 0; j < 2; j++)
                    {
                        categoryOfDish              = new CategoryOfDish();
                        categoryOfDish.CategoryId   = "CategoryId" + j;
                        categoryOfDish.CategoryName = "CategoryName" + j;
                        categoryOfDish.ListDish.AddRange(ListDish);
                        lstCategoryOfDish.Add(categoryOfDish);
                    }
                    for (int i = 0; i < 2; i++)
                    {
                        CategoryOnStore           = new CategoryOnStore();
                        CategoryOnStore.StoreId   = "StoreId" + i;
                        CategoryOnStore.StoreName = "Store Name" + i;
                        CategoryOnStore.ListCategory.AddRange(lstCategoryOfDish);
                        ListCatgoryOnstoreChoose.Add(CategoryOnStore);
                    }



                    ////end create data test=======================================================


                    XLWorkbook wb = _factory.Report(model, ListCatgoryOnstoreChoose, ListModifierChoose);

                    ViewBag.wb = wb;
                    string sheetName = string.Format("Report_Detail Itemized Sales Analysis Modifiers view_{0}", DateTime.Now.ToString("MMddyyyy")).Replace(" ", "_");
                    Response.Clear();
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.Charset         = System.Text.UTF8Encoding.UTF8.WebName;
                    Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
                    if (model.FormatExport.Equals(Commons.Html))
                    {
                        Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.html", sheetName));
                    }
                    else
                    {
                        Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                        Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.xlsx", sheetName));
                    }
                    using (var memoryStream = new MemoryStream())
                    {
                        wb.SaveAs(memoryStream);
                        if (model.FormatExport.Equals(Commons.Html))
                        {
                            Workbook workbook = new Workbook();
                            workbook.LoadFromStream(memoryStream);
                            //convert Excel to HTML
                            Worksheet sheet = workbook.Worksheets[0];
                            using (var ms = new MemoryStream())
                            {
                                sheet.SaveToHtml(ms);
                                ms.WriteTo(HttpContext.Response.OutputStream);
                                ms.Close();
                            }
                        }
                        else
                        {
                            memoryStream.WriteTo(HttpContext.Response.OutputStream);
                        }
                        memoryStream.Close();
                    }
                    HttpContext.Response.End();
                    return(View("Index", model));
                }
                catch (Exception ex)
                {
                    _logger.Error("Report_Detail Itemized Sales Analysis Modifiers view error: " + ex);
                    return(new HttpStatusCodeResult(400, ex.Message));
                }
            }
        }
Ejemplo n.º 50
0
        protected override void Seed(OrderContext db)
        {
            CookerType ct1 = new CookerType
            {
                Name = "Oven"
            };

            CookerType ct2 = new CookerType
            {
                Name = "Microwave"
            };

            Dish d1 = new Dish
            {
                Name        = "Salad",
                CookingTime = TimeSpan.FromSeconds(45),
                Weight      = 500
            };

            Dish d2 = new Dish
            {
                Name        = "Soup",
                CookingTime = TimeSpan.FromMinutes(5),
                CookerType  = ct1,
                Weight      = 450
            };

            Dish d3 = new Dish
            {
                Name        = "Pizza",
                CookingTime = TimeSpan.FromMinutes(3),
                CookerType  = ct2,
                Weight      = 600
            };

            Dish d4 = new Dish
            {
                Name        = "Pasta",
                CookingTime = TimeSpan.FromMinutes(10),
                CookerType  = ct1,
                Weight      = 250
            };

            Cook c1 = new Cook
            {
                SkillCoefficient = 1.2f,
                FinishTime       = DateTime.Now.AddHours(1)
            };

            Cook c2 = new Cook
            {
                SkillCoefficient = 1.5f,
                FinishTime       = DateTime.Now.AddHours(1)
            };

            Cooker cr1 = new Cooker
            {
                CookerType  = ct1,
                CoolingTime = TimeSpan.FromHours(1),
                WarmUpTime  = TimeSpan.FromHours(2),
                FinishTime  = DateTime.Now.AddHours(-2)
            };

            Cooker cr2 = new Cooker
            {
                CookerType  = ct2,
                CoolingTime = TimeSpan.FromSeconds(30),
                WarmUpTime  = TimeSpan.FromSeconds(30),
                FinishTime  = DateTime.Now
            };

            db.CookerTypes.Add(ct1);
            db.CookerTypes.Add(ct2);

            db.Dishes.Add(d1);
            db.Dishes.Add(d2);
            db.Dishes.Add(d3);
            db.Dishes.Add(d4);

            db.Cooks.Add(c1);
            db.Cooks.Add(c2);

            db.Cookers.Add(cr1);
            db.Cookers.Add(cr2);

            db.SaveChanges();
        }
Ejemplo n.º 51
0
 public async void ScrollCellContent(Dish _dish)
 {
     dish        = _dish;
     name.text   = _dish.name;
     img.texture = await LoadImg(dish.img[0].url);
 }
 public Dish CreateDish(Dish dish)
 {
     _db.Dishes.Add(dish);
     _db.SaveChanges();
     return(dish);
 }
Ejemplo n.º 53
0
        public IActionResult EditDish(int id)
        {
            Dish thisDish = dbContext.Dishes.SingleOrDefault(dish => dish.DishId == id);

            return(View(thisDish));
        }
Ejemplo n.º 54
0
 private Domain.Dish ModelFrom(Dish entity)
 {
     return(new Domain.Dish(entity.Id, entity.Name));
 }
Ejemplo n.º 55
0
        public IActionResult EditDishView(int dishid)
        {
            Dish oneDish = dbContext.Dishes.Single(d => d.DishId == dishid);

            return(View(oneDish));
        }
Ejemplo n.º 56
0
        public static bool DeleteDish(Dish dish)
        {
            int data = Data.ScalarQuery($"delete Dish where id = {dish.ID};");

            return(data > 0 ? true : false);
        }
Ejemplo n.º 57
0
        protected override async Task<bool> Save()
        {

            var dish = new Dish();
            dish.Id = Id;
            dish.DishGroup = SelecteDishGroup;
            dish.DishGroupId = SelecteDishGroup.Id;
            dish.Name = Name;
            dish.Price = Price;

            DishImage image = null;
            if (_imageWasChanged)
            {
                image = new DishImage();
                image.Image = GetImage();
            }
            else if (_dish?.DishImageId != null)
                {
                    image = new DishImage();
                    image.Id = _dish.DishImageId.Value;
                }
            

            List<DishIngredient> ingredients = null;
            if (DishIngredients.Any())
            {
                ingredients = DishIngredients.Select(t => new DishIngredient
                {
                    Id = t.Id,
                    DishId = Id,
                    IngredientId = t.IngredientId,
                    Weight = t.Weight
                }).ToList();
            }

            var result = await Repository.SaveDish(dish, image, ingredients);
            Id = dish.Id;

            if (result)
            {
                MessageBox.Show("Успешно сохранено", "Сохранение");
            }
            return result;
        }
Ejemplo n.º 58
0
 protected DishDecorator(Dish dish)
 {
     Dish = dish;
 }
Ejemplo n.º 59
0
        public void Test04DishkStorage()
        {
            var placeId = GetPlace().Id;
            var categories = GetCategories();
            IDishStorage dishStorage = (IDishStorage)_storageFactory.GetStorage<Dish>();

            /* 'Сухие Вина'
               'Горячие блюда'
               'Каши'
               'Вина' */
            // add some dishes
            var dishesInit = new Dish[,]
            {
            {
                    new Dish() { Name= "Шато", Price=456},
                    new Dish() { Name="Бардо", Price=987},
                    new Dish() { Name="Мерло", Price=159.7m},
                    new Dish() { Name="Отмерло", Price=753}
                },
            {
                    new Dish() { Name= "Борщ", Price=45m},
                    new Dish(){ Name="Щи", Price=95},
                    new Dish(){ Name="Солянка", Price=82.5m},
                    new Dish(){ Name="Малянка", Price=187}
                },
                {
                    new Dish() { Name= "Гречневая", Price=12},
                    new Dish(){ Name="Манная", Price=13.4m},
                    new Dish(){ Name="Пшенная", Price=14},
                    new Dish(){ Name="Геркулесная", Price=16}
                }
            };
            List<Dish> dishes = new List<Dish>();
            for (int c = 0; c < 3; c++)
            {
                for (int d = 0; d < 4; d++)
                {
                    dishesInit[c, d].CategoryId = categories[c].Id;
                    var dish = dishStorage.Add(dishesInit[c, d]);
                    dishes.Add(dish);
                    Assert.IsNotNull(dish);
                    Assert.IsTrue(dish.Id > 0);
                }
            }

            // edit dish
            dishes[3].Name = "Игристое";
            dishes[3] = dishStorage.Set(dishes[3].Id, dishes[3]);

            // get dish
            var dish0 = dishStorage.Get(dishes[0].Id);
            Assert.AreEqual(dishes[0].Id, dish0.Id);
            Assert.AreEqual(dishes[0].Name, dish0.Name);
            Assert.AreEqual(dishes[0].Price, dish0.Price);
            Assert.AreEqual(dishes[0].CategoryId, dish0.CategoryId);
            Assert.AreEqual(dishes[0].Description, dish0.Description);

            // delete dish
            dishStorage.Delete(dishes[3].Id);

            // get dishes
            Assert.IsTrue(dishStorage.GetAllOfPlace(placeId).Count() == 11);

            // get dishes
            Assert.IsTrue(dishStorage.GetAllOfCategory(categories[1].Id).Count() == 4);
        }
Ejemplo n.º 60
0
 public IActionResult Creating(Dish NewDish)
 {
     db.Dishes.Add(NewDish);
     db.SaveChanges();
     return(RedirectToAction("DishHome"));
 }