Exemplo n.º 1
0
        static void ChangeProduct()
        {
            Product        product     = new Product();
            List <Product> productList = new List <Product>();

            Console.WriteLine("Mehsulun kodunu daxil edin");
            string Code = Console.ReadLine();
            var    list = marketableService.ChangeProduct(Code);

            if (list.Count == 0)
            {
                Console.WriteLine("Bu koda uygun mehsul yoxdur");
            }
            else
            {
                #region Name
                Console.WriteLine("Mehsulun yeni adini daxil edin");
                string NewName = Console.ReadLine();
                #endregion
                #region Price
                Console.WriteLine("Yeni qiymet daxil edin");
                string Price = Console.ReadLine();
                double NewPrice;

                while (!double.TryParse(Price, out NewPrice))
                {
                    Console.WriteLine("Duzgun qiymet daxil edin");
                    Price = Console.ReadLine();
                }
                product.ProductPrice = NewPrice;
                #endregion
                #region Count
                Console.WriteLine("Yeni say daxil edin");
                string Count = Console.ReadLine();
                int    NewCount;
                while (!int.TryParse(Count, out NewCount))
                {
                    Console.WriteLine("Duzgun say daxil edin");
                    Count = Console.ReadLine();
                }
                #endregion
                #region category
                Console.WriteLine("Kateqoriya sechin");
                Array array = Enum.GetValues(typeof(Category));
                foreach (var item2 in array)
                {
                    Console.Write(Array.IndexOf(array, item2) + 1);
                    Console.WriteLine("-{0}", item2);
                }
                int    Selection;
                string Select = Console.ReadLine();
                while (!int.TryParse(Select, out Selection))
                {
                    Console.WriteLine("Reqem daxil etmelisiniz");
                    Select = Console.ReadLine();
                }

                switch (Selection)
                {
                case 1:
                    product.Category = Category.Ichkiler;
                    break;

                case 2:
                    product.Category = Category.Meyveler;
                    break;

                case 3:
                    product.Category = Category.Shokoladlar;
                    break;

                case 4:
                    product.Category = Category.Terevezler;
                    break;

                case 5:
                    product.Category = Category.UnMehsullari;
                    break;

                case 6:
                    product.Category = Category.Yaglar;
                    break;

                default:
                    Console.WriteLine("Kateqoriyanin qarshisindaki reqemi daxil edin");
                    break;
                }


                #endregion
                foreach (var item in list)
                {
                    item.ProductName  = NewName;
                    item.ProductPrice = NewPrice;
                    item.ProductCount = NewCount;
                    item.Category     = product.Category;
                }
                marketableService.ChangeProduct(Code);
                Console.WriteLine("=======Mehsul deyishdirildi=======");
            }
        }
Exemplo n.º 2
0
        static void ShowProductChange()
        {
            Product product = new Product();


            #region Product Change
            Console.WriteLine("~~~~~~~~ Mehsulda uzerinde deyisiklik etmek~~~~~~~~");
            Console.WriteLine("");
            #endregion

            #region Product Code
            Console.WriteLine("Dəyişiklik etmək istediyiniz məhsulun Kodu daxil edin");
            string code = Console.ReadLine();

            #endregion

            List <Product> ProductChangeCode = _marketableService.ChangeProduct(code);

            if (ProductChangeCode.Count == 0)
            {
                Console.WriteLine("");
                Console.WriteLine("___________Məhsulun kodu dogru deyil___________");
                Console.WriteLine("");
            }
            else
            {
                #region Product New Name
                Console.WriteLine("");
                Console.WriteLine("Mehsulun yeni adini daxil edin");
                string productName = Console.ReadLine();
                #endregion

                #region Product New Quantity
                Console.WriteLine("");
                Console.WriteLine("Məhsulun yeni sayini daxil edin");
                string productQuantityInput = Console.ReadLine();
                int    productQuantity;

                while (!int.TryParse(productQuantityInput, out productQuantity))
                {
                    Console.WriteLine("Rəqəm daxil etməlisiniz!");
                    productQuantityInput = Console.ReadLine();
                }
                #endregion

                #region Product New Price
                Console.WriteLine("");
                Console.WriteLine("Məhsulun yeni məbləği daxil edin ");
                string productPriceInput = Console.ReadLine();
                double productPrice;

                while (!double.TryParse(productPriceInput, out productPrice))
                {
                    Console.WriteLine("Rəqəm daxil etməlisiniz! ");
                    productPriceInput = Console.ReadLine();
                }
                #endregion



                int selectInt;
                do
                {
                    #region Product kategory Menu

                    Console.WriteLine("~~~~~~~~kategoriya daxil edin~~~~~~~~");

                    Console.WriteLine("0. Televizor");
                    Console.WriteLine("1. Computer");
                    Console.WriteLine("2. Phone");
                    Console.WriteLine("3. Saat");
                    #endregion

                    #region Product kategory Selection
                    Console.WriteLine("");

                    Console.WriteLine("Seçiminizi Edin:");

                    string select = Console.ReadLine();
                    while (!int.TryParse(select, out selectInt))
                    {
                        Console.WriteLine("Reqem daxil etmelisiniz!");
                        select = Console.ReadLine();
                    }
                    #endregion

                    #region Product kategory Switch

                    switch (selectInt)
                    {
                    case 0:
                        product.Category = CategoryType.Televizor;
                        break;

                    case 1:
                        product.Category = CategoryType.Computer;
                        break;

                    case 2:
                        product.Category = CategoryType.Phone;
                        break;

                    case 3:
                        product.Category = CategoryType.Saat;
                        break;

                    default:
                        Console.WriteLine("------------------------");
                        Console.WriteLine("Siz yalniş secim etdiniz, 0-3 araliğinda seçim etməlisiniz");
                        Console.WriteLine("------------------------");
                        break;
                    }
                } while (selectInt == -1);


                #endregion

                foreach (var item in ProductChangeCode)
                {
                    item.Category        = (CategoryType)selectInt;
                    item.ProductName     = productName;
                    item.ProductQuantity = productQuantity;
                    item.ProductPrice    = productPrice;


                    Console.WriteLine("~~~~~~~~~~~~~~~~~~~");
                    Console.WriteLine("");
                    Console.WriteLine("Məhsul üzərində dəyişiklik edildi");
                    Console.WriteLine("");
                    Console.WriteLine("~~~~~~~~~~~~~~~~~~~");
                }
            }
        }