public async Task <IActionResult> PutMainCourse(int id, MainCourse mainCourse)
        {
            if (id != mainCourse.Id)
            {
                return(BadRequest());
            }

            _context.Entry(mainCourse).State = EntityState.Modified;

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

            return(NoContent());
        }
Beispiel #2
0
        public IMainCourse CreateMainCourse(string name, decimal price, int calories, int quantityPerServing, int timeToPrepare, bool isVegan, string type)
        {
            var mainCourse = new MainCourse(name, price, calories, quantityPerServing, timeToPrepare, isVegan,
                                            GetMainCourseType(type));

            return(mainCourse);
        }
Beispiel #3
0
        public IProduct CreatePOCOProduct(Product product)
        {
            IProduct pocoProduct = null;

            switch (product.ProductType)
            {
            case ProductType.Pizza:
                pocoProduct = new Pizza(product.Name, product.Price, product.Remarks);
                break;

            case ProductType.PizzaTopping:
                pocoProduct = new PizzaTopping(product.Name, product.Price);
                break;

            case ProductType.MainCourse:
                pocoProduct = new MainCourse(product.Name, product.Price);
                break;

            case ProductType.MainCourseSideDish:
                pocoProduct = new MainCourseSideDish(product.Name, product.Price);
                break;

            case ProductType.Beverage:
                pocoProduct = new Beverage(product.Name, product.Price);
                break;

            case ProductType.Soup:
                pocoProduct = new Soup(product.Name, product.Price);
                break;

            default:
                break;
            }
            return(pocoProduct);
        }
        public void SetUp()
        {
            _customer = new FakeCustomer();
            _choices  = new List <CustomerChoice>();
            _table    = new Table {
                TableNumber = 9
            };

            var dish = new Starter {
                Id = 1, Name = "GreenSalad", Price = 15.00, Description = "This is health and green"
            };
            var option = OptionDishesTypes.WithLessSalt;

            var dish2 = new MainCourse {
                Id = 2, Name = "Filet Mignon", Price = 35.00, Description = "Delicious red meat"
            };
            var option2 = OptionDishesTypes.PreparedSpicy;

            var customerChoice = _customer.OrderDish(dish, option);

            _choices.Add(customerChoice);

            var customerChoice2 = _customer.OrderDish(dish2, option2);

            _choices.Add(customerChoice2);
        }
Beispiel #5
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type)
            {
            case "Dessert":
                food = new Dessert(name, price);
                break;

            case "MainCourse":
                food = new MainCourse(name, price);
                break;

            case "Salad":
                food = new Salad(name, price);
                break;

            case "Soup":
                food = new Soup(name, price);
                break;
            }

            menu.Add(food);

            return($"Added {name} ({type}) with price {price:f2} to the pool");
        }
Beispiel #6
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
            }

            else if (type == "Soup")
            {
                food = new Soup(name, price);
            }

            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
            }

            if (food != null)
            {
                this.menu.Add(food);
            }


            return($"Added {food.Name} ({food.GetType().Name}) with price {food.Price:F2} to the pool");
        }
Beispiel #7
0
        public IFood CreateFood(string type, string name, decimal price)
        {
            IFood food = null;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
            }
            else if (type == "Soup")
            {
                food = new Soup(name, price);
            }
            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
            }
            else
            {
                throw new InvalidOperationException("Invalid food type!");
            }

            return(food);
        }
        //[ValidateAntiForgeryToken]
        public async Task <JsonResult> CreateMainCourse([FromBody] MainCourseInfo mainCourseInfo)
        {
            string emailAddress = HttpContext.User.Identity.Name;

            var restaurant = await _context.Restaurant
                             .Where(rest => rest.EmailAddress.Equals(emailAddress))
                             .FirstOrDefaultAsync();

            if (checkMainCourseNameInSameRestaurant(mainCourseInfo.Name, restaurant.Id))
            {
                HttpContext.Response.StatusCode = 400;
                return(new JsonResult("MainCourse " + mainCourseInfo.Name + " already exists in restaurant"));
            }

            MainCourse newMainCourse = new MainCourse
            {
                Name         = mainCourseInfo.Name,
                Description  = mainCourseInfo.Description,
                Price        = mainCourseInfo.Price,
                HouseSpecial = mainCourseInfo.HouseSpecial
            };

            if (ModelState.IsValid)
            {
                newMainCourse.RestaurantId = restaurant.Id;

                _context.Add(newMainCourse);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index), new { id = id });
            }

            HttpContext.Response.StatusCode = 200;
            return(new JsonResult("MainCourse successfully created"));
        }
Beispiel #9
0
        public IFood Create(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type)
            {
            case "Dessert":
                food = new Dessert(name, price);
                break;

            case "MainCourse":
                food = new MainCourse(name, price);
                break;

            case "Salad":
                food = new Salad(name, price);
                break;

            case "Soup":
                food = new Soup(name, price);
                break;
            }

            return(food);
        }
        public string AddFood(string type, string name, decimal price)
        {
            IFood  food   = null;
            string output = string.Empty;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            else if (type == "Soup")
            {
                food = new Soup(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            return(output);
        }
        public async Task <IActionResult> EditMainCourse([FromBody] MainCourseInfo mainCourseInfo)
        {
            string emailAddress = HttpContext.User.Identity.Name;

            var restaurant = await _context.Restaurant
                             .Where(rest => rest.EmailAddress.Equals(emailAddress))
                             .FirstOrDefaultAsync();

            string mainCourseName = Request.Headers["mainCourseName"];

            MainCourse mainCourseToUpdate = await _context.MainCourse
                                            .Where(d => d.Name.Equals(mainCourseName))
                                            .FirstOrDefaultAsync();

            mainCourseToUpdate.Name         = mainCourseInfo.Name;
            mainCourseToUpdate.Price        = mainCourseInfo.Price;
            mainCourseToUpdate.Description  = mainCourseInfo.Description;
            mainCourseToUpdate.HouseSpecial = mainCourseInfo.HouseSpecial;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mainCourseToUpdate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
            }

            HttpContext.Response.StatusCode = 200;
            return(new JsonResult("MainCourse successfully updated"));
        }
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type.ToLower())
            {
            case "dessert":
                food = new Dessert(name, price);
                break;

            case "salad":
                food = new Salad(name, price);
                break;

            case "soup":
                food = new Soup(name, price);
                break;

            case "maincourse":
                food = new MainCourse(name, price);
                break;

            default: throw new ArgumentException($"Invalid food type {type}!");
            }

            this.menu.Add(food);
            return($"Added {food.Name} ({type}) with price {food.Price:f2} to the pool");
        }
        public async Task <ActionResult <MainCourse> > PostMainCourse(MainCourse mainCourse)
        {
            _context.MainCourse.Add(mainCourse);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMainCourse", new { id = mainCourse.Id }, mainCourse));
        }
Beispiel #14
0
 public void SetUp()
 {
     _mainCourse = new MainCourse {
         Id = 2, Name = "Filet Mignon", Price = 35.00, Description = "Delicious red meat"
     };
     _mockOptionPrepare = new Mock <BaseOptionPrepare>();
     _mockOptionPrepare.Setup(_ => _.IsOptionActive).Returns(true);
 }
        public void TestMethod2() // test sprawdzajacy czy 2 osobne zamówienia będą miały ten sam nr
        {
            //Arrange
            Product        mc    = new MainCourse("Schabowy z fryktami", 30);
            Product        pizza = new Pizza("Pizza Tosca z podwójnym serem", 27);
            Product        cola  = new DrinkSoup("Cola", 5);
            List <Product> list  = new List <Product>();

            list.Add(mc);
            list.Add(pizza);
            list.Add(cola);

            //Act
            Order order  = new Order(list);
            Order order2 = new Order(list);

            //Assert
            Assert.IsTrue(order.Get_Order_Nr() != order2.Get_Order_Nr());
        }
        public void TestMethod1()         // Test metody czy string który zwraca jest w postaci html
        {
            //Arrange
            Product        mc    = new MainCourse("Schabowy z fryktami", 30);
            Product        pizza = new Pizza("Pizza Tosca z podwójnym serem", 27);
            Product        cola  = new DrinkSoup("Cola", 5);
            List <Product> list  = new List <Product>();

            list.Add(mc);
            list.Add(pizza);
            list.Add(cola);
            Order order = new Order(list);

            //Act
            string htmlText = MailSender.ContentEmail(order);

            //htmlText = "cos"; // powinien byc blad

            //Assert
            Assert.IsTrue(htmlText != HttpUtility.HtmlEncode(htmlText)); // konwertuje text na html
        }
Beispiel #17
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type)
            {
            case "Dessert":
                food = new Dessert(name, price);
                break;

            case "MainCourse":
                food = new MainCourse(name, price);
                break;

            case "Salad":
                food = new Salad(name, price);
                break;

            case "Soup":
                food = new Soup(name, price);
                break;

            default:
                break;
            }

            string result = string.Empty;

            if (food != null)
            {
                this.menu.Add(food);
                result = string.Format(OutputMessages.FoodMade,
                                       name,
                                       food.GetType().Name,
                                       food.Price);
            }

            return(result);
        }
        public async Task <JsonResult> DeleteMainCourse()
        {
            string mainCourseName = Request.Headers["mainCourseName"];

            // check if mainCourse exists in database
            if (!MainCourseNameExists(mainCourseName))
            {
                // mainCourse not found
                HttpContext.Response.StatusCode = 400;
                return(new JsonResult("MainCourse doesn't exist"));
            }

            MainCourse mainCourseToDelete = await _context.MainCourse
                                            .Where(d => d.Name.Equals(mainCourseName))
                                            .FirstOrDefaultAsync();

            _context.MainCourse.Remove(mainCourseToDelete);
            await _context.SaveChangesAsync();

            HttpContext.Response.StatusCode = 200;
            return(new JsonResult("MainCourse successfully deleted"));
        }
Beispiel #19
0
        public Food CreateFood(string type, string name, decimal price)
        {
            Food food = null;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
            }
            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
            }
            else if (type == "Soup")
            {
                food = new Soup(name, price);
            }

            return(food);
        }
Beispiel #20
0
        public IFood CreateFood(string foodType, string foodName, decimal foodPrice)
        {
            IFood createdFood = null;

            switch (foodType.ToLower())
            {
            case "dessert":
                createdFood = new Dessert(foodName, foodPrice);
                break;

            case "maincourse":
                createdFood = new MainCourse(foodName, foodPrice);
                break;

            case "salad":
                createdFood = new Salad(foodName, foodPrice);
                break;

            case "soup":
                createdFood = new Soup(foodName, foodPrice);
                break;
            }
            return(createdFood);
        }
Beispiel #21
0
        public IFood Create(string type, string name, decimal price)
        {
            switch (type)
            {
            case "Dessert":
                IFood desert = new Dessert(name, price);
                return(desert);

            case "MainCourse":
                IFood mainCourse = new MainCourse(name, price);
                return(mainCourse);

            case "Salad":
                IFood salad = new Salad(name, price);
                return(salad);

            case "Soup":
                IFood soup = new Soup(name, price);
                return(soup);

            default:
                return(null);
            }
        }
Beispiel #22
0
        private void SubmitButton_Click_1(object sender, EventArgs e)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(Properties.Settings.Default.backendHostname + "/" + menuValue + "/Restaurant/create");

            httpWebRequest.Headers["Authorization"] = "Basic " + AuthValue;
            httpWebRequest.ContentType = "text/json";
            httpWebRequest.Accept      = "*/*";
            httpWebRequest.Method      = "POST";
            string json = "";

            if (menuValue != "Salad" && menuValue != "Drink")
            {
                mainCourse      = new MainCourse();
                mainCourse.Name = NameBox.Text;
                try
                {
                    mainCourse.Price = Convert.ToDouble(PriceBox.Text);
                    if (mainCourse.Price == 0)
                    {
                        throw new ArgumentNullException("Invalid value");
                    }
                }
                catch (Exception error)
                {
                    ResultLabel.Text = "Price should be number.";
                    return;
                }
                mainCourse.Description  = DescriptionTextBox.Text;
                mainCourse.HouseSpecial = HouseSpecialCheckBox.Checked;
                json = Newtonsoft.Json.JsonConvert.SerializeObject(mainCourse);
            }
            else if (menuValue == "Salad")
            {
                salad      = new Salad();
                salad.Name = NameBox.Text;
                try
                {
                    salad.Price = Convert.ToDouble(PriceBox.Text);
                    if (salad.Price == 0)
                    {
                        throw new ArgumentNullException("Invalid value");
                    }
                }
                catch (Exception error)
                {
                    ResultLabel.Text = "Price should be number.";
                    return;
                }
                salad.Description  = DescriptionTextBox.Text;
                salad.HouseSpecial = HouseSpecialCheckBox.Checked;
                salad.Topping      = toppingBox.Text;
                json = Newtonsoft.Json.JsonConvert.SerializeObject(salad);
            }
            else if (menuValue == "Drink")
            {
                drink      = new Drink();
                drink.Name = NameBox.Text;
                try
                {
                    drink.Price = Convert.ToDouble(PriceBox.Text);
                    if (drink.Price == 0)
                    {
                        throw new ArgumentNullException("Invalid value");
                    }
                }
                catch (Exception error)
                {
                    ResultLabel.Text = "Price should be number.";
                    return;
                }
                drink.Description   = DescriptionTextBox.Text;
                drink.HouseSpecial  = HouseSpecialCheckBox.Checked;
                drink.AgeRestricted = ageRestrictedCheckbox.Checked;
                json = Newtonsoft.Json.JsonConvert.SerializeObject(drink);
            }
            httpWebRequest.ContentLength = Encoding.ASCII.GetBytes(json).Length;


            try
            {
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    streamWriter.Write(json);
                }
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                if (httpResponse.StatusCode.ToString() == "OK")
                {
                    ResultLabel.Text = "SUCCESS!";
                    clearBoxes();
                }
            }
            catch (System.Net.WebException error)
            {
                ResultLabel.Text = "Failed!";
            }
        }
Beispiel #23
0
 public void TearDown()
 {
     _mainCourse        = null;
     _mockOptionPrepare = null;
 }
Beispiel #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (panel1.Visible)
            {
                string json = "";
                if (menuValue != "Salad" && menuValue != "Drink")
                {
                    MainCourse mainCourse = new MainCourse();
                    mainCourse              = new MainCourse();
                    mainCourse.Name         = NameBox.Text;
                    mainCourse.Price        = Convert.ToDouble(PriceBox.Text);
                    mainCourse.Description  = DescriptionTextBox.Text;
                    mainCourse.HouseSpecial = HouseSpecialCheckBox.Checked;
                    json = Newtonsoft.Json.JsonConvert.SerializeObject(mainCourse);
                }
                else if (menuValue == "Salad")
                {
                    salad              = new Salad();
                    salad.Name         = NameBox.Text;
                    salad.Price        = Convert.ToDouble(PriceBox.Text);
                    salad.Description  = DescriptionTextBox.Text;
                    salad.HouseSpecial = HouseSpecialCheckBox.Checked;
                    salad.Topping      = toppingBox.Text;
                    json = Newtonsoft.Json.JsonConvert.SerializeObject(salad);
                }
                else if (menuValue == "Drink")
                {
                    drink               = new Drink();
                    drink.Name          = NameBox.Text;
                    drink.Price         = Convert.ToDouble(PriceBox.Text);
                    drink.Description   = DescriptionTextBox.Text;
                    drink.HouseSpecial  = HouseSpecialCheckBox.Checked;
                    drink.AgeRestricted = ageRestrictedCheckbox.Checked;
                    json = Newtonsoft.Json.JsonConvert.SerializeObject(drink);
                }

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(Properties.Settings.Default.backendHostname + "/" + menuValue + "/Restaurant/edit");
                httpWebRequest.Headers["Authorization"] = "Basic " + AuthValue;
                httpWebRequest.Headers[char.ToLower(menuValue[0]) + menuValue.Substring(1) + "Name"] = old.Name;
                httpWebRequest.ContentType = "text/json";
                httpWebRequest.Accept      = "*/*";
                httpWebRequest.Method      = "POST";

                try
                {
                    httpWebRequest.ContentLength = Encoding.ASCII.GetBytes(json).Length;

                    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                    {
                        streamWriter.Write(json);
                    }
                    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    if (httpResponse.StatusCode.ToString() == "OK")
                    {
                    }
                }
                catch (System.Net.WebException error)
                {
                    MessageBox.Show(error.ToString());
                }

                panel1.Hide();
                MenuGrid.Show();
                button1.Text = "Choose";
                getJsonMenu();
            }
            else
            {
                DataGridViewRow row = MenuGrid.CurrentRow;
                if (menuValue != "Salad" && menuValue != "Drink")
                {
                    MainCourse mainCourse = new MainCourse();
                    mainCourse.Name         = (string)row.Cells["Name"].Value;
                    mainCourse.Price        = (double)row.Cells["Price"].Value;
                    mainCourse.Description  = (string)row.Cells["Description"].Value;
                    mainCourse.HouseSpecial = (bool)row.Cells["Housespecial"].Value;
                    old           = mainCourse;
                    NameBox.Text  = mainCourse.Name;
                    PriceBox.Text = (string)mainCourse.Price.ToString();
                    HouseSpecialCheckBox.Checked = mainCourse.HouseSpecial;
                    DescriptionTextBox.Text      = mainCourse.Description;
                }
                else if (menuValue == "Salad")
                {
                    Salad mainCourse = new Salad();
                    mainCourse.Name         = (string)row.Cells["Name"].Value;
                    mainCourse.Price        = (double)row.Cells["Price"].Value;
                    mainCourse.Description  = (string)row.Cells["Description"].Value;
                    mainCourse.HouseSpecial = (bool)row.Cells["Housespecial"].Value;
                    mainCourse.Topping      = (string)row.Cells["Topping"].Value;
                    old           = mainCourse;
                    NameBox.Text  = mainCourse.Name;
                    PriceBox.Text = (string)mainCourse.Price.ToString();
                    HouseSpecialCheckBox.Checked = mainCourse.HouseSpecial;
                    DescriptionTextBox.Text      = mainCourse.Description;
                    toppingBox.Text = mainCourse.Topping;
                }
                else if (menuValue == "Drink")
                {
                    Drink mainCourse = new Drink();
                    mainCourse.Name          = (string)row.Cells["Name"].Value;
                    mainCourse.Price         = (double)row.Cells["Price"].Value;
                    mainCourse.Description   = (string)row.Cells["Description"].Value;
                    mainCourse.HouseSpecial  = (bool)row.Cells["Housespecial"].Value;
                    mainCourse.AgeRestricted = (bool)row.Cells["AgeRestricted"].Value;
                    old           = mainCourse;
                    NameBox.Text  = mainCourse.Name;
                    PriceBox.Text = (string)mainCourse.Price.ToString();
                    HouseSpecialCheckBox.Checked  = mainCourse.HouseSpecial;
                    DescriptionTextBox.Text       = mainCourse.Description;
                    ageRestrictedCheckbox.Checked = mainCourse.AgeRestricted;
                }

                panel1.Show();
                MenuGrid.Hide();
                button1.Text = "Submit";
            }
        }
 public Client(IAbstractFactory factory)
 {
     Soup       = factory.CreateSoup();
     Drink      = factory.CreateDrink();
     MainCourse = factory.CreateMainCourse();
 }
        // kod dla Forms Menu
        #region Menu
        public static Product SelectedDish(System.Windows.Forms.ComboBox comboBoxMainDishes1, System.Windows.Forms.ComboBox comboMainDishes2, System.Windows.Forms.ComboBox comboBoxAdditions, Dictionary <string, double> products)
        {
            // jeśli wybrano głowne danie z indeksu od 0 do 3 to stwórz obiekt product i w razie czego udekoruj (dodaj dodatek)
            if (comboBoxMainDishes1.SelectedIndex >= 0 && comboBoxMainDishes1.SelectedIndex <= 3)
            {
                string name = (comboBoxMainDishes1.SelectedItem.ToString()); // przypisz nazwę obiektu z comboBoxMainDishes1
                double cost;
                try
                {
                    cost = products[name];   // wybierz z kolekcji products odpowiedni produkt i przekaż jego wartość
                }
                catch (KeyNotFoundException) // szukany klucz nie isnieje to przerwij działanie funkcji ("łapie" błąd)
                {
                    MessageBox.Show("Podane danie nie istnieje", "Wybierz danie",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information); // wyświetl komunikat
                    return(null);
                }

                // stwórz obiekt product o podanej nazwie (name) i kwocie (cost)
                Product product = new Pizza(name, cost);
                // jeśli został wybrany dodatek to udekoruj product
                if (comboBoxAdditions.SelectedItem != null && comboBoxMainDishes1.SelectedIndex > 0)
                {
                    switch (comboBoxAdditions.SelectedIndex)
                    {
                    case 1:
                        product = new PizzaDoubleCheese(product);     // pizza z podwójnym serem
                        break;

                    case 2:
                        product = new PizzaSalami(product);     // pizza z salami
                        break;

                    case 3:
                        product = new PizzaHam(product);     // pizza z szynką
                        break;

                    case 4:
                        product = new PizzaChampignons(product);     // pizza z pieczarkami
                        break;

                    default:
                        break;
                    }
                }

                return(product);
            }
            // jeśli wybrano głowne danie z indeksu od 4 to stwórz obiekt product i w razie czego udekoruj (dodaj dodatek)
            else if (comboBoxMainDishes1.SelectedIndex == 4)
            {
                StringBuilder name = new StringBuilder(comboBoxMainDishes1.SelectedItem.ToString()); // przypisz nazwę obiektu (string) z comboBoxMainDishes1
                comboMainDishes2.BackColor = Color.White;                                            // ustaw okno wyboru głownego dania na kolor biały
                if (comboMainDishes2.SelectedItem != null)                                           // gdy zostało wybrane pole dodatku do dania głownego (np. dla schabowego frytki, ziemniaki, ryż)
                {
                    double cost;
                    try
                    {
                        cost = products[name.ToString()]; // wybierz z kolekcji products odpowiedni produkt i przekaż jego wartość
                    }
                    catch (KeyNotFoundException)          // szukany klucz nie isnieje to przerwij działanie funkcji ("łapie" błąd)
                    {
                        MessageBox.Show("Podane danie nie istnieje", "Wybierz danie",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information); // wyświetl komunikat
                        return(null);
                    }
                    name.Append(" " + comboMainDishes2.SelectedItem.ToString()); // dopisz nazwę obiektu (string) z comboBoxMainDishes2

                    Product product = new MainCourse(name.ToString(), cost);     // stwórz obiekt product o podanej nazwie (name) i kwocie (cost)
                    // jeśli wybrano dodatki to udekoruj product
                    if (comboBoxAdditions.SelectedItem != null && comboBoxAdditions.SelectedIndex > 0)
                    {
                        switch (comboBoxAdditions.SelectedIndex)
                        {
                        case 1:
                            product = new MainCourseSalads(product);     // z sałatkami
                            break;

                        case 2:
                            product = new MainCourseSauces(product);     // z sosami
                            break;
                        }
                    }
                    comboMainDishes2.SelectedItem = null;  // ustaw comboMainDishes2 wybrany indeks na null aby zapobiec "zapisaniu" dania następnego jako poprzednie

                    return(product);
                }
                else
                {
                    MessageBox.Show("Wybierz z czym chcesz to danie", "Wybierz danie",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    comboMainDishes2.BackColor = Color.LightBlue;       // okienko pojawia się jeśli nie wybrano dodatku do dania głównego
                    return(null);
                }
            }
            // jeśli wybrano głowne danie z indeksu od 5 do 6 to stwórz obiekt product i w razie czego udekoruj (dodaj dodatek)
            else if (comboBoxMainDishes1.SelectedIndex > 4 && comboBoxMainDishes1.SelectedIndex <= 6)
            {
                string name = comboBoxMainDishes1.SelectedItem.ToString();   // przypisz nazwę obiektu (string) z comboBoxMainDishes1
                double cost;
                try
                {
                    cost = products[name];   // wybierz z kolekcji products odpowiedni produkt i przekaż jego wartość
                }
                catch (KeyNotFoundException) // szukany klucz nie isnieje to przerwij działanie funkcji ("łapie" błąd)
                {
                    MessageBox.Show("Podane danie nie istnieje", "Wybierz danie",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information); // wyświetl komunikat
                    return(null);
                }

                Product product = new MainCourse(name, cost);  // stwórz obiekt product o podanej nazwie (name) i kwocie (cost)
                // jeśli wybrano dodatki to udekoruj product
                if (comboBoxAdditions.SelectedItem != null && comboBoxAdditions.SelectedIndex > 0)
                {
                    switch (comboBoxAdditions.SelectedIndex)
                    {
                    case 1:
                        product = new MainCourseSalads(product);     // z sałatkami
                        break;

                    case 2:
                        product = new MainCourseSauces(product);     // z sosami
                        break;
                    }
                }

                return(product);
            }
            else if (comboBoxMainDishes1.SelectedIndex > 6 && comboBoxMainDishes1.SelectedIndex <= 11) // jeśli wybrano głowne danie z indeksu od 7 do 11 to stwórz obiekt product
            {
                string name = comboBoxMainDishes1.SelectedItem.ToString();                             // przypisz nazwę obiektu (string) z comboBoxMainDishes1
                double cost;
                try
                {
                    cost = products[name];     // wybierz z kolekcji products odpowiedni produkt i przekaż jego wartość
                }
                catch (KeyNotFoundException)   // szukany klucz nie isnieje to przerwij działanie funkcji ("łapie" błąd)
                {
                    MessageBox.Show("Podane danie nie istnieje", "Wybierz danie",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information); // wyświetl komunikat
                    return(null);
                }

                Product product = new DrinkSoup(name, cost); // stwórz obiekt product o nazwie (name) i cenie (cost)
                return(product);
            }
            else   // jeśli wybrano indeks powyżej 11 to wyświetl komunikat że podane danie nie istnieje
            {
                MessageBox.Show("Podane danie nie istnieje", "Wybierz danie",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return(null);
            }
        }