Example #1
0
        public static void Initialize(PizzaContext context)
        {
            //  context.Database.EnsureCreated();

            if (context.Employees.Any())
            {
                return;
            }

            Employee[] employees = new Employee[]
            {
                new Employee {
                    FirstName = "Jessee", LastName = "Prescot", PhoneNumber = "12345", Role = Roles.Manager, Salary = 4000
                },
                new Employee {
                    FirstName = "Jim", LastName = "Smith", PhoneNumber = "12345", Role = Roles.AssitantManager, Salary = 3500
                },
                new Employee {
                    FirstName = "Bob", LastName = "Anderson", PhoneNumber = "12345", Role = Roles.Cashier, Salary = 30000
                }
            };

            context.Employees.AddRange(employees);
            //foreach(Employee employee in employees)
            //{
            //    context.Employees.Add(employee);
            //}
            //use Addrange instead of Add no need foreach

            context.SaveChanges();
        }
        /// <summary>
        /// Initialize using dependency injection
        /// </summary>
        /// <param name="context"></param>
        public static void Initialize(PizzaContext context)
        {
            // ensures database created. remove later to use migrations
            context.Database.EnsureCreated();

            // check to see if there are any roles in employees table
            if (context.Employees.Any())
            {
                return;
            }

            Employee[] employees = new Employee[]
            {
                new Employee {
                    FirstName = "Jesse", LastName = "Pinkman", PhoneNumber = "123-333-444", Role = Roles.Manager, Salary = 100000M
                },
                new Employee {
                    FirstName = "Skylar", LastName = "White", PhoneNumber = "123-333-444", Role = Roles.AssistantManager, Salary = 75000M
                },
                new Employee {
                    FirstName = "Walter", LastName = "White", PhoneNumber = "123-333-444", Role = Roles.Cashier, Salary = 25000M
                }
            };

            // addRange takes in collectionn and adds it
            context.Employees.AddRange(employees);

            //save changes
            context.SaveChanges();
        }
Example #3
0
        public static void Initialize(PizzaContext context)
        {
            //context.Database.EnsureCreated();

            if (context.Employees.Any())
            {
                return;
            }

            Employee[] employees = new Employee[]
            {
                new Employee {
                    FirstName = "Jessie", LastName = "Prescott", PhoneNumber = "123-123-1234", Role = Roles.Manager, Salary = 100000M
                }
                , new Employee {
                    FirstName = "Billy", LastName = "Smith", PhoneNumber = "123-123-1234", Role = Roles.AssistantManager, Salary = 40000M
                }
                , new Employee {
                    FirstName = "Johnathon", LastName = "Walsh", PhoneNumber = "123-123-1234", Role = Roles.Driver, Salary = 10000M
                }
            };

            context.Employees.AddRange(employees);
            context.SaveChanges();
        }
Example #4
0
        public static void Initialize(PizzaContext context)
        {
            if (context.Employees.Any())
            {
                return;
            }

            Employe[] employees = new Employe[]
            {
                new Employe {
                    FirstName = "John", LastName = "Prescot", PhoneNumber = "123-1234-1356", Role = Roles.Manager, Salary = 40000
                },
                new Employe {
                    FirstName = "Jim", LastName = "Smith", PhoneNumber = "123-4324-1326", Role = Roles.AssistantManager, Salary = 15000
                },
                new Employe {
                    FirstName = "Bob", LastName = "Anderson", PhoneNumber = "123-1234-1356", Role = Roles.Cashier, Salary = 8000
                }
            };

            context.Employees.AddRange(employees);
            context.SaveChanges();
        }
Example #5
0
        public static void Initialize(PizzaContext context)
        {
            //context.Database.EnsureCreated();

            if (context.Employees.Any())
            {
                return;
            }

            Employee[] employees = new Employee[]
            {
                new Employee {
                    FirstName = "John", LastName = "Cornishon", PhoneNumber = "123123", Role = Roles.Manager, Salary = 100000
                },
                new Employee {
                    FirstName = "John", LastName = "Cornishon", PhoneNumber = "123123", Role = Roles.Manager, Salary = 100000
                }
            };


            context.Employees.AddRange(employees);
            context.SaveChanges();
        }