Beispiel #1
0
 public void Insert(Vendedor obj)
 {
     _context.Add(obj);
     _context.SaveChanges();
 }
Beispiel #2
0
        public void Seed()
        {
            if (_context.Departamento.Any() ||
                _context.Vendedor.Any() ||
                _context.Vendas.Any())
            {
                return;
            }


            Departamento d1 = new Departamento(1, "Computers");
            Departamento d2 = new Departamento(2, "Electrônicos");
            Departamento d3 = new Departamento(3, "Eletros");
            Departamento d4 = new Departamento(4, "Livros");

            Vendedor s1 = new Vendedor(1, "Bob Brown", "*****@*****.**", new DateTime(1998, 4, 21), 1000.0, d1);
            Vendedor s2 = new Vendedor(2, "Maria Green", "*****@*****.**", new DateTime(1979, 12, 31), 3500.0, d2);
            Vendedor s3 = new Vendedor(3, "Alex Grey", "*****@*****.**", new DateTime(1988, 1, 15), 2200.0, d1);
            Vendedor s4 = new Vendedor(4, "Martha Red", "*****@*****.**", new DateTime(1993, 11, 30), 3000.0, d4);
            Vendedor s5 = new Vendedor(5, "Donald Blue", "*****@*****.**", new DateTime(2000, 1, 9), 4000.0, d3);
            Vendedor s6 = new Vendedor(6, "Alex Pink", "*****@*****.**", new DateTime(1997, 3, 4), 3000.0, d2);

            Vendas r1  = new Vendas(1, new DateTime(2018, 09, 25), 11000.0, StatusDaVenda.Faturado, s1);
            Vendas r2  = new Vendas(2, new DateTime(2018, 09, 4), 7000.0, StatusDaVenda.Faturado, s5);
            Vendas r3  = new Vendas(3, new DateTime(2018, 09, 13), 4000.0, StatusDaVenda.Cancelado, s4);
            Vendas r4  = new Vendas(4, new DateTime(2018, 09, 1), 8000.0, StatusDaVenda.Faturado, s1);
            Vendas r5  = new Vendas(5, new DateTime(2018, 09, 21), 3000.0, StatusDaVenda.Faturado, s3);
            Vendas r6  = new Vendas(6, new DateTime(2018, 09, 15), 2000.0, StatusDaVenda.Faturado, s1);
            Vendas r7  = new Vendas(7, new DateTime(2018, 09, 28), 13000.0, StatusDaVenda.Faturado, s2);
            Vendas r8  = new Vendas(8, new DateTime(2018, 09, 11), 4000.0, StatusDaVenda.Faturado, s4);
            Vendas r9  = new Vendas(9, new DateTime(2018, 09, 14), 11000.0, StatusDaVenda.Pendente, s6);
            Vendas r10 = new Vendas(10, new DateTime(2018, 09, 7), 9000.0, StatusDaVenda.Faturado, s6);
            Vendas r11 = new Vendas(11, new DateTime(2018, 09, 13), 6000.0, StatusDaVenda.Faturado, s2);
            Vendas r12 = new Vendas(12, new DateTime(2018, 09, 25), 7000.0, StatusDaVenda.Pendente, s3);
            Vendas r13 = new Vendas(13, new DateTime(2018, 09, 29), 10000.0, StatusDaVenda.Faturado, s4);
            Vendas r14 = new Vendas(14, new DateTime(2018, 09, 4), 3000.0, StatusDaVenda.Faturado, s5);
            Vendas r15 = new Vendas(15, new DateTime(2018, 09, 12), 4000.0, StatusDaVenda.Faturado, s1);
            Vendas r16 = new Vendas(16, new DateTime(2018, 10, 5), 2000.0, StatusDaVenda.Faturado, s4);
            Vendas r17 = new Vendas(17, new DateTime(2018, 10, 1), 12000.0, StatusDaVenda.Faturado, s1);
            Vendas r18 = new Vendas(18, new DateTime(2018, 10, 24), 6000.0, StatusDaVenda.Faturado, s3);
            Vendas r19 = new Vendas(19, new DateTime(2018, 10, 22), 8000.0, StatusDaVenda.Faturado, s5);
            Vendas r20 = new Vendas(20, new DateTime(2018, 10, 15), 8000.0, StatusDaVenda.Faturado, s6);
            Vendas r21 = new Vendas(21, new DateTime(2018, 10, 17), 9000.0, StatusDaVenda.Faturado, s2);
            Vendas r22 = new Vendas(22, new DateTime(2018, 10, 24), 4000.0, StatusDaVenda.Faturado, s4);
            Vendas r23 = new Vendas(23, new DateTime(2018, 10, 19), 11000.0, StatusDaVenda.Cancelado, s2);
            Vendas r24 = new Vendas(24, new DateTime(2018, 10, 12), 8000.0, StatusDaVenda.Faturado, s5);
            Vendas r25 = new Vendas(25, new DateTime(2018, 10, 31), 7000.0, StatusDaVenda.Faturado, s3);
            Vendas r26 = new Vendas(26, new DateTime(2018, 10, 6), 5000.0, StatusDaVenda.Faturado, s4);
            Vendas r27 = new Vendas(27, new DateTime(2018, 10, 13), 9000.0, StatusDaVenda.Pendente, s1);
            Vendas r28 = new Vendas(28, new DateTime(2018, 10, 7), 4000.0, StatusDaVenda.Faturado, s3);
            Vendas r29 = new Vendas(29, new DateTime(2018, 10, 23), 12000.0, StatusDaVenda.Faturado, s5);
            Vendas r30 = new Vendas(30, new DateTime(2018, 10, 12), 5000.0, StatusDaVenda.Faturado, s2);

            _context.Departamento.AddRange(d1, d2, d3, d4);

            _context.Vendedor.AddRange(s1, s2, s3, s4, s5, s6);

            _context.Vendas.AddRange(
                r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
                r11, r12, r13, r14, r15, r16, r17, r18, r19, r20,
                r21, r22, r23, r24, r25, r26, r27, r28, r29, r30
                );

            _context.SaveChanges();
        }
        public void Seed()
        {
            if (_context.Department.Any() || _context.Seller.Any() || _context.SalesRecord.Any())
            {
                return; // banco ja foi populado
            }
            Department d1 = new Department(1, "HERTZ");
            Department d2 = new Department(2, "FRANCHISING");
            Department d3 = new Department(3, "GESTÃO DE FROTAS");
            Department d4 = new Department(4, "SEMINOVOS");

            Seller s1 = new Seller(1, "Jose Luiz", "*****@*****.**", new DateTime(1998, 4, 21), 1000.0, d1);
            Seller s2 = new Seller(2, "Jonh House", "*****@*****.**", new DateTime(1979, 12, 31), 3500.0, d2);
            Seller s3 = new Seller(3, "Julia Silva", "*****@*****.**", new DateTime(1988, 1, 15), 2200.0, d1);
            Seller s4 = new Seller(4, "Ana Gomes", "*****@*****.**", new DateTime(1993, 11, 30), 3000.0, d4);
            Seller s5 = new Seller(5, "Maria Luiza", "*****@*****.**", new DateTime(2000, 1, 9), 4000.0, d3);
            Seller s6 = new Seller(6, "Alex OLiveira", "*****@*****.**", new DateTime(1997, 3, 4), 3000.0, d2);

            SalesRecord r1  = new SalesRecord(1, new DateTime(2020, 01, 25), 6000.0, SaleStatus.Billed, s1);
            SalesRecord r2  = new SalesRecord(2, new DateTime(2020, 01, 4), 12000.0, SaleStatus.Billed, s5);
            SalesRecord r3  = new SalesRecord(3, new DateTime(2020, 01, 13), 3000.0, SaleStatus.Canceled, s4);
            SalesRecord r4  = new SalesRecord(4, new DateTime(2020, 01, 1), 7000.0, SaleStatus.Billed, s1);
            SalesRecord r5  = new SalesRecord(5, new DateTime(2020, 01, 21), 4000.0, SaleStatus.Billed, s3);
            SalesRecord r6  = new SalesRecord(6, new DateTime(2020, 01, 15), 3000.0, SaleStatus.Billed, s1);
            SalesRecord r7  = new SalesRecord(7, new DateTime(2020, 01, 28), 10000.0, SaleStatus.Billed, s2);
            SalesRecord r8  = new SalesRecord(8, new DateTime(2020, 01, 11), 3000.0, SaleStatus.Billed, s4);
            SalesRecord r9  = new SalesRecord(9, new DateTime(2020, 01, 14), 10000.0, SaleStatus.Pending, s6);
            SalesRecord r10 = new SalesRecord(10, new DateTime(2020, 01, 7), 8000.0, SaleStatus.Billed, s6);
            SalesRecord r11 = new SalesRecord(11, new DateTime(2020, 01, 13), 5000.0, SaleStatus.Billed, s2);
            SalesRecord r12 = new SalesRecord(12, new DateTime(2020, 01, 25), 6000.0, SaleStatus.Pending, s3);
            SalesRecord r13 = new SalesRecord(13, new DateTime(2020, 02, 29), 9000.0, SaleStatus.Billed, s4);
            SalesRecord r14 = new SalesRecord(14, new DateTime(2020, 02, 4), 6000.0, SaleStatus.Billed, s5);
            SalesRecord r15 = new SalesRecord(15, new DateTime(2020, 02, 12), 5000.0, SaleStatus.Billed, s1);
            SalesRecord r16 = new SalesRecord(16, new DateTime(2020, 02, 5), 1000.0, SaleStatus.Billed, s4);
            SalesRecord r17 = new SalesRecord(17, new DateTime(2020, 02, 1), 14000.0, SaleStatus.Billed, s1);
            SalesRecord r18 = new SalesRecord(18, new DateTime(2020, 02, 24), 3000.0, SaleStatus.Billed, s3);
            SalesRecord r19 = new SalesRecord(19, new DateTime(2020, 02, 22), 8000.0, SaleStatus.Billed, s5);
            SalesRecord r20 = new SalesRecord(20, new DateTime(2020, 03, 15), 5000.0, SaleStatus.Billed, s6);
            SalesRecord r21 = new SalesRecord(21, new DateTime(2020, 03, 17), 10000.0, SaleStatus.Billed, s2);
            SalesRecord r22 = new SalesRecord(22, new DateTime(2020, 03, 24), 2000.0, SaleStatus.Billed, s4);
            SalesRecord r23 = new SalesRecord(23, new DateTime(2020, 03, 19), 12000.0, SaleStatus.Canceled, s2);
            SalesRecord r24 = new SalesRecord(24, new DateTime(2020, 03, 12), 7000.0, SaleStatus.Billed, s5);
            SalesRecord r25 = new SalesRecord(25, new DateTime(2020, 03, 31), 3000.0, SaleStatus.Billed, s3);
            SalesRecord r26 = new SalesRecord(26, new DateTime(2020, 04, 6), 5000.0, SaleStatus.Billed, s4);
            SalesRecord r27 = new SalesRecord(27, new DateTime(2020, 04, 13), 2000.0, SaleStatus.Pending, s1);
            SalesRecord r28 = new SalesRecord(28, new DateTime(2020, 04, 7), 7000.0, SaleStatus.Billed, s3);
            SalesRecord r29 = new SalesRecord(29, new DateTime(2020, 04, 23), 11000.0, SaleStatus.Billed, s5);
            SalesRecord r30 = new SalesRecord(30, new DateTime(2020, 04, 12), 2000.0, SaleStatus.Billed, s2);

            _context.Department.AddRange(d1, d2, d3, d4);

            _context.Seller.AddRange(s1, s2, s3, s4, s5, s6);

            _context.SalesRecord.AddRange(
                r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
                r11, r12, r13, r14, r15, r16, r17, r18, r19, r20,
                r21, r22, r23, r24, r25, r26, r27, r28, r29, r30
                );

            _context.SaveChanges();
        }