private static void SaveSalesmen(ShopDbContext db) { var salesmen = Console.ReadLine().Split(";"); foreach (var salesman in salesmen) { db.Add(new Salesman { Name = salesman }); } db.SaveChanges(); }
private static void SaveReview(ShopDbContext db, string arguments) { var parts = arguments.Split(';'); var customerId = int.Parse(parts[0]); var itemId = int.Parse(parts[1]); var review = new Review { CustomerId = customerId, ItemId = itemId }; db.Add(review); db.SaveChanges(); }
private static void RegisterCustomer(ShopDbContext db, string arguments) { var parts = arguments.Split(';'); var customerName = parts[0]; var salesmanId = int.Parse(parts[1]); db.Add(new Customer { Name = customerName, SalesmanId = salesmanId }); db.SaveChanges(); }
private static void MakeOrder(ShopDbContext db, string arguments) { int[] commandArgs = arguments.Split(';').Select(int.Parse).ToArray(); int customerId = commandArgs[0]; Order order = new Order { CustomerId = customerId }; for (int i = 1; i < commandArgs.Length; i++) { var itemId = commandArgs[i]; order.Items.Add(new OrderItem { ItemId = itemId }); } db.Add(order); db.SaveChanges(); }
private static void SaveOrder(ShopDbContext db, string arguments) { var parts = arguments.Split(';'); var customerId = int.Parse(parts[0]); var order = new Order { CustomerId = customerId }; for (int i = 1; i < parts.Length; i++) { var itemId = int.Parse(parts[i]); order.Items.Add(new OrderItem { ItemId = itemId }); } db.Add(order); db.SaveChanges(); }
private static void SaveItems(ShopDbContext db) { while (true) { var line = Console.ReadLine(); if (line == "END") { break; } var parts = line.Split(';'); var itemName = parts[0]; var itemPrice = decimal.Parse(parts[1]); db.Add(new Item { Name = itemName, Price = itemPrice }); } db.SaveChanges(); }