Exemplo n.º 1
0
        public static void FillSalesman(AppDbContext context)
        {
            string[] input = Console.ReadLine().Split(';');

            foreach (var salesmanName in input)
            {
                Salesmen salesman = new Salesmen {
                    Name = salesmanName
                };
                context.Salesmen.Add(salesman);
            }
            context.SaveChanges();
        }
Exemplo n.º 2
0
        public static void Register(AppDbContext context, string input)
        {
            string[] tokens = input.Split(';');

            string name       = tokens[0];
            int    salesmenId = int.Parse(tokens[1]);

            Customer customer = new Customer()
            {
                Name = name
            };

            Salesmen salesmen = context.Salesmen.FirstOrDefault(s => s.Id == salesmenId);

            salesmen.Customers.Add(customer);

            context.SaveChanges();
        }