Ejemplo n.º 1
0
        public void Seed()
        {
            if (_context.Departament.Any() || _context.Seller.Any() || _context.SalesRecords.Any())
            {
                return;
            }

            //Seeding Departaments
            Departament d1 = new Departament(1, "Electronics");
            Departament d2 = new Departament(2, "House");
            Departament d3 = new Departament(3, "Clotches");
            Departament d4 = new Departament(4, "Gardeen");

            //Seeding Sellers
            Seller s1 = new Seller(1, "Milton", "*****@*****.**", new DateTime(1974, 01, 03), 1000.0, d1);
            Seller s2 = new Seller(2, "Roberta", "*****@*****.**", new DateTime(1979, 04, 10), 1500.0, d1);
            Seller s3 = new Seller(3, "Arthur", "*****@*****.**", new DateTime(1999, 02, 15), 2000.0, d2);
            Seller s4 = new Seller(4, "Esther", "*****@*****.**", new DateTime(2000, 07, 25), 1500.0, d2);
            Seller s5 = new Seller(5, "Victor Hugo", "*****@*****.**", new DateTime(2001, 09, 20), 2000.0, d3);
            Seller s6 = new Seller(6, "Daniela", "*****@*****.**", new DateTime(1976, 09, 17), 1500.0, d3);
            Seller s7 = new Seller(7, "Denise", "*****@*****.**", new DateTime(1980, 05, 21), 2000.0, d4);
            Seller s8 = new Seller(8, "Eduardo", "*****@*****.**", new DateTime(1974, 04, 26), 1500.0, d4);

            //Seeding Sales Records
            SalesRecord r1  = new SalesRecord(1, new DateTime(2019, 04, 15), 3500.0, SalesStatus.Billed, s1);
            SalesRecord r2  = new SalesRecord(2, new DateTime(2019, 04, 16), 1650.0, SalesStatus.Pending, s1);
            SalesRecord r3  = new SalesRecord(3, new DateTime(2019, 04, 15), 4850.0, SalesStatus.Billed, s2);
            SalesRecord r4  = new SalesRecord(4, new DateTime(2019, 04, 17), 789.0, SalesStatus.Billed, s2);
            SalesRecord r5  = new SalesRecord(5, new DateTime(2019, 04, 15), 680.0, SalesStatus.Pending, s3);
            SalesRecord r6  = new SalesRecord(6, new DateTime(2019, 04, 15), 1180.5, SalesStatus.Pending, s3);
            SalesRecord r7  = new SalesRecord(7, new DateTime(2019, 04, 15), 185.2, SalesStatus.Billed, s4);
            SalesRecord r8  = new SalesRecord(8, new DateTime(2019, 04, 19), 796.0, SalesStatus.Billed, s4);
            SalesRecord r9  = new SalesRecord(9, new DateTime(2019, 04, 16), 810.9, SalesStatus.Canceled, s5);
            SalesRecord r10 = new SalesRecord(10, new DateTime(2019, 04, 19), 1259.1, SalesStatus.Billed, s5);
            SalesRecord r11 = new SalesRecord(11, new DateTime(2019, 04, 15), 254.3, SalesStatus.Canceled, s6);
            SalesRecord r12 = new SalesRecord(12, new DateTime(2019, 04, 18), 1187.0, SalesStatus.Canceled, s6);
            SalesRecord r13 = new SalesRecord(13, new DateTime(2019, 04, 15), 351.25, SalesStatus.Pending, s7);
            SalesRecord r14 = new SalesRecord(14, new DateTime(2019, 04, 17), 925.21, SalesStatus.Pending, s7);
            SalesRecord r15 = new SalesRecord(15, new DateTime(2019, 04, 17), 687.28, SalesStatus.Billed, s8);
            SalesRecord r16 = new SalesRecord(16, new DateTime(2019, 04, 19), 463.44, SalesStatus.Billed, s8);

            //Update entities
            _context.Departament.AddRange(d1, d2, d3, d4);
            _context.Seller.AddRange(s1, s2, s3, s4, s5, s6, s7, s8);
            _context.SalesRecords.AddRange(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16);

            //Commit changes
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Seed()
        {
            if (_context.Department.Any() ||
                _context.Seller.Any() ||
                _context.SalesRecord.Any())
            {
                return; // if happines some value in entitys, don't will create another database
            }

            //Departamentos.
            Department d1 = new Department(1, "Fashion");
            Department d2 = new Department(2, "Eletronics");
            Department d3 = new Department(3, "Computers");
            Department d4 = new Department(4, "Clocks");
            Department d5 = new Department(5, "Boots");

            //Vendedores
            Seller s1 = new Seller(1, "João marcos", "joã[email protected]", new DateTime(1997, 5, 2), 2000.00, d2);
            Seller s2 = new Seller(2, "Gabriela oliveira", "joã[email protected]", new DateTime(1999, 8, 12), 1500.00, d1);
            Seller s3 = new Seller(3, "Hamilton júnior", "*****@*****.**", new DateTime(1995, 7, 15), 1500.00, d5);
            Seller s4 = new Seller(4, "Frederico da silta", "*****@*****.**", new DateTime(1998, 3, 11), 5000.00, d3);
            Seller s5 = new Seller(5, "Edmundo oliveira", "*****@*****.**", new DateTime(1994, 6, 12), 2500.00, d4);
            Seller s6 = new Seller(6, "Gabriel", "*****@*****.**", new DateTime(1994, 6, 12), 2500.00, d4);

            //Salles Record
            SalesRecord sr1 = new SalesRecord(1, new DateTime(2019, 12, 12), 5000.00, Models.Enums.SalesStatus.PEDING, s1);
            SalesRecord sr2 = new SalesRecord(2, new DateTime(2018, 10, 3), 10.000, Models.Enums.SalesStatus.CANCELED, s2);
            SalesRecord sr3 = new SalesRecord(3, new DateTime(2017, 06, 3), 8.000, Models.Enums.SalesStatus.BILLED, s3);
            SalesRecord sr4 = new SalesRecord(4, new DateTime(2015, 05, 3), 200.000, Models.Enums.SalesStatus.PEDING, s4);
            SalesRecord sr5 = new SalesRecord(5, new DateTime(2016, 01, 20), 75.000, Models.Enums.SalesStatus.BILLED, s5);
            SalesRecord sr6 = new SalesRecord(6, new DateTime(2013, 02, 14), 55.000, Models.Enums.SalesStatus.PEDING, s6);

            _context.Department.AddRange(d1, d2, d3, d4, d5);            //Saving departments
            _context.Seller.AddRange(s1, s2, s3, s4, s5, s6);            //Saving sellers
            _context.SalesRecord.AddRange(sr1, sr2, sr3, sr4, sr5, sr6); //Saving Sales Record

            _context.SaveChanges();
        }
        public void Seed()
        {
            if (_context.Department.Any() ||
                _context.Seller.Any() ||
                _context.SalesRecord.Any())
            {
                return; // DB has been seeded
            }

            Department d1 = new Department(1, "Computers");
            Department d2 = new Department(2, "Electronics");
            Department d3 = new Department(3, "Fashino");
            Department d4 = new Department(4, "Books");

            Seller s1 = new Seller(1, "Bob Brown", "*****@*****.**", new DateTime(1998, 4, 21), 1000.0, d1);

            SalesRecord r1 = new SalesRecord(1, new DateTime(2018, 09, 25), 11000.0, SaleStatus.Billed, s1);

            _context.Department.AddRange(d1, d2, d3, d4);
            _context.Seller.AddRange(s1);
            _context.SalesRecord.AddRange(r1);

            _context.SaveChanges();
        }
Ejemplo n.º 4
0
        public void Seed()
        {
            if (_context.Department.Any() ||
                _context.Seller.Any() ||
                _context.SalesRecord.Any())
            {
                return; // DB has been seeded
            }

            Department d1 = new Department(1, "Computer");
            Department d2 = new Department(2, "Eletronics");
            Department d3 = new Department(3, "Fashion");
            Department d4 = new Department(4, "Books");

            Seller s1 = new Seller(1, "Bob Brown", "*****@*****.**", new DateTime(1998, 4, 21), 1000.00, d1);
            Seller s2 = new Seller(2, "Maria Green", "*****@*****.**", new DateTime(1979, 12, 31), 3500.00, d2);
            Seller s3 = new Seller(3, "Alex Grey", "*****@*****.**", new DateTime(1988, 1, 15), 2200.00, d1);
            Seller s4 = new Seller(4, "Martha Red", "*****@*****.**", new DateTime(1993, 11, 30), 3000.00, d4);
            Seller s5 = new Seller(5, "Donald Blue", "*****@*****.**", new DateTime(200, 1, 9), 4000.00, d3);
            Seller s6 = new Seller(6, "Alex Pink", "*****@*****.**", new DateTime(1997, 3, 4), 3000.00, d2);


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