Example #1
0
        static void AddWayBill()
        {
            Batch batch = new Batch();

            Console.WriteLine("Введите действие по партии (прибытие или отгрузка)");
            string action = Console.ReadLine().ToLower();

            while (action != "прибытие" && action != "отгрузка")
            {
                Console.WriteLine("Повторите, пожалуйста ввод");
                action = Console.ReadLine().ToLower();
            }
            batch.Action            = action;
            batch.Date              = DateTime.Now;
            batch.ProductsInBatches = new List <ProductsInBatch>();
            do
            {
                if (batch.ProductsInBatches.Count > 0)
                {
                    Console.WriteLine("Если вы закончили добавлять продукты введите 'выход'");
                }
                ProductsInBatch productsInBatch = new ProductsInBatch();
                Console.WriteLine("Введите продукт ");
                string command = Console.ReadLine();
                if (command.ToLower() == "выход")
                {
                    break;
                }
                Product product = productRepository.Get(command);
                if (product != null)
                {
                    productsInBatch.ProductName = product.Name;
                }
                else
                {
                    Console.WriteLine("Такого продукта в базе нет. Повторите ввод!");
                    continue;
                }

                Console.WriteLine("Введите количество");
                productsInBatch.Quantity = Convert.ToInt32(Console.ReadLine());
                batch.ProductsInBatches.Add(productsInBatch);
            } while (true);
            batchRepository.Create(batch);
            batchRepository.SaveChanges();
            Console.WriteLine("Накладная добавлена!");
        }
 public void Delete(ProductsInBatch productsInBatch)
 {
     db.ProductsInBatches.Remove(productsInBatch);
 }
 public void Create(ProductsInBatch productsInBatch)
 {
     db.ProductsInBatches.Add(productsInBatch);
 }