Пример #1
0
        private static void RegisterCustomer(ShopHirarchyDBContext db, string args)
        {
            var tokens     = args.Split(';');
            var name       = tokens[0];
            var salesmanId = int.Parse(tokens[1]);

            db.Customers.Add(new Customer
            {
                Name       = name,
                SalesmanId = salesmanId
            });
            db.SaveChanges();
        }
Пример #2
0
        private static void FillSalesman(ShopHirarchyDBContext db)
        {
            var inputSalesmans = Console.ReadLine().Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var sMan in inputSalesmans)
            {
                var salesman = new Salesman
                {
                    Name = sMan
                };
                db.Salesmans.Add(salesman);
            }
            db.SaveChanges();
        }
Пример #3
0
        private static void RegisterReview(ShopHirarchyDBContext db, string args)
        {
            var tokens = args.Split(';');
            var id     = int.Parse(tokens[0]);
            var itemId = int.Parse(tokens[1]);

            db.Reviews.Add(new Review
            {
                CustomerId = id,
                ItemId     = itemId
            });

            db.SaveChanges();
        }
Пример #4
0
        private static void ReadItemCommand(ShopHirarchyDBContext db)
        {
            string inputLine;

            while ((inputLine = Console.ReadLine()) != "END")
            {
                var tokens = inputLine.Split(';');
                var name   = tokens[0];
                var price  = decimal.Parse(tokens[1]);

                db.Items.Add(new Item
                {
                    Name  = name,
                    Price = price
                });
            }
            db.SaveChanges();
        }
Пример #5
0
        private static void RegisterOrder(ShopHirarchyDBContext db, string args)
        {
            var tokens = args.Split(';');
            var id     = int.Parse(tokens[0]);

            var order = new Order
            {
                CustomerId = id
            };

            for (int i = 1; i < tokens.Length; i++)
            {
                var itemId = int.Parse(tokens[i]);
                order.Item.Add(new ItemOrder
                {
                    ItemId = itemId
                });
            }
            db.Add(order);
            db.SaveChanges();
        }