示例#1
0
        public static DatabaseContext LoadData(DatabaseContext context)
        {
            DataLoader.LoadProducts();
            Employee Test1 = new Employee()
            {
                Emp_Id    = "EMP01",
                User_Name = "khprasad123",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "DEPT_EMPLOYEE",
                Full_Name = "Hariprasad",
            };


            //Department Head
            Employee Test2 = new Employee()
            {
                Emp_Id    = "EMP02",
                User_Name = "logu",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "DEPT_HEAD",
                Full_Name = "Logu Rajeswari",
            };

            Employee Test3 = new Employee()
            {
                Emp_Id    = "EMP03",
                User_Name = "chad",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "DEPT_EMPLOYEE",
                Full_Name = "Chad Gosh Coder",
            };

            Employee Test4 = new Employee()
            {
                Emp_Id    = "EMP04",
                User_Name = "alvin",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "STORE_CLERK",
                Full_Name = "Alvin Thalaiva",
            };
            Employee Test5 = new Employee()
            {
                Emp_Id    = "EMP05",
                User_Name = "anu",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "STORE_MANAGER",
                Full_Name = "Annapoorni Mahadevan",
            };
            Employee Test6 = new Employee()
            {
                Emp_Id    = "EMP06",
                User_Name = "daniel",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "STORE_SUPERVISOR",
                Full_Name = "Daniel The Coder",
            };
            Employee Test7 = new Employee()
            {
                Emp_Id    = "EMP07",
                User_Name = "ariel",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "DEPT_EMPLOYEE",
                Full_Name = "Ariel the Angel",
            };

            Employee Test8 = new Employee()
            {
                Emp_Id    = "EMP08",
                User_Name = "logesh",
                Password  = "******",
                Email     = "*****@*****.**",
                Role      = "DEPT_EMPLOYEE",
                Full_Name = "Lokesh Android King",
            };

            context.employees.AddOrUpdate(Test1);
            context.employees.AddOrUpdate(Test2);
            context.employees.AddOrUpdate(Test3);
            context.employees.AddOrUpdate(Test4);
            context.employees.AddOrUpdate(Test5);
            context.employees.AddOrUpdate(Test6);
            context.employees.AddOrUpdate(Test7);
            context.employees.AddOrUpdate(Test8);
            context.SaveChanges();

            Department Dept = new Department()
            {
                Dep_Name        = "CSE",
                Dept_id         = "DEP001",
                Phone           = "234324234",
                CollectionPoint = "Morning 6 30 At PlayGround",
                Dept_Head_Id    = Test2.Emp_Id, // Employee logu is the Department Head
                Dept_Rep_Id     = Test3.Emp_Id  // as of now chad is the department rep
            };

            //ASSSIGNED CHAD AS THE DEFAULT DEPARTMENT REP

            Test1.Department = Dept; Test1.Dept_Id = Dept.Dept_id;
            Test2.Department = Dept; Test2.Dept_Id = Dept.Dept_id;
            Test3.Department = Dept; Test3.Dept_Id = Dept.Dept_id;
            Test4.Department = Dept; Test4.Dept_Id = Dept.Dept_id;
            Test5.Department = Dept; Test5.Dept_Id = Dept.Dept_id;
            Test6.Department = Dept; Test6.Dept_Id = Dept.Dept_id;
            Test7.Department = Dept; Test7.Dept_Id = Dept.Dept_id;
            Test8.Department = Dept; Test8.Dept_Id = Dept.Dept_id;



            Dept.Employees.Add(Test1);
            Dept.Employees.Add(Test2);
            Dept.Employees.Add(Test3);
            Dept.Employees.Add(Test4);
            Dept.Employees.Add(Test5);
            Dept.Employees.Add(Test6);
            Dept.Employees.Add(Test7);
            Dept.Employees.Add(Test8);


            context.employees.AddOrUpdate(Test1);
            context.employees.AddOrUpdate(Test2);
            context.employees.AddOrUpdate(Test3);
            context.employees.AddOrUpdate(Test4);
            context.employees.AddOrUpdate(Test5);
            context.employees.AddOrUpdate(Test6);
            context.employees.AddOrUpdate(Test7);
            context.employees.AddOrUpdate(Test8);

            context.departments.AddOrUpdate(Dept);
            context.SaveChanges();



            return(context);
        }
示例#2
0
        public static InventoryDbContext LoadData(InventoryDbContext context)
        {
            DataLoader.LoadProducts();

            User u = new User();

            u.id       = "1";
            u.userName = "******";
            MD5 md5 = new MD5CryptoServiceProvider();

            Byte[] originalBytes = ASCIIEncoding.Default.GetBytes("venkat");
            Byte[] encodedBytes  = md5.ComputeHash(originalBytes);
            u.password   = BitConverter.ToString(encodedBytes);
            u.employeeId = "10017";

            User u2 = new User();

            u2.id       = "2";
            u2.userName = "******";
            MD5 md5_1 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_1 = ASCIIEncoding.Default.GetBytes("diwei");
            Byte[] encodedBytes_1  = md5_1.ComputeHash(originalBytes_1);
            u2.password   = BitConverter.ToString(encodedBytes_1);
            u2.employeeId = "10016";

            User u3 = new User();

            u3.id       = "3";
            u3.userName = "******";
            MD5 md5_2 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_2 = ASCIIEncoding.Default.GetBytes("zhongbao");
            Byte[] encodedBytes_2  = md5_2.ComputeHash(originalBytes_2);
            u3.password   = BitConverter.ToString(encodedBytes_2);
            u3.employeeId = "10022";

            User u4 = new User();

            u4.id       = "4";
            u4.userName = "******";
            MD5 md5_3 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_3 = ASCIIEncoding.Default.GetBytes("siqi");
            Byte[] encodedBytes_3  = md5_3.ComputeHash(originalBytes_3);
            u4.password   = BitConverter.ToString(encodedBytes_3);
            u4.employeeId = "10020";

            User u5 = new User();

            u5.id       = "5";
            u5.userName = "******";
            MD5 md5_4 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_4 = ASCIIEncoding.Default.GetBytes("soonleng");
            Byte[] encodedBytes_4  = md5_4.ComputeHash(originalBytes_4);
            u5.password   = BitConverter.ToString(encodedBytes_4);
            u5.employeeId = "10021";

            User u6 = new User();

            u6.id       = "6";
            u6.userName = "******";
            MD5 md5_5 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_5 = ASCIIEncoding.Default.GetBytes("denghan");
            Byte[] encodedBytes_5  = md5_5.ComputeHash(originalBytes_5);
            u6.password   = BitConverter.ToString(encodedBytes_5);
            u6.employeeId = "10018";

            User u7 = new User();

            u7.id       = "7";
            u7.userName = "******";
            MD5 md5_6 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_6 = ASCIIEncoding.Default.GetBytes("victoria");
            Byte[] encodedBytes_6  = md5_6.ComputeHash(originalBytes_6);
            u7.password   = BitConverter.ToString(encodedBytes_6);
            u7.employeeId = "10023";

            User u8 = new User();

            u8.id       = "8";
            u8.userName = "******";
            MD5 md5_7 = new MD5CryptoServiceProvider();

            Byte[] originalBytes_7 = ASCIIEncoding.Default.GetBytes("annie");
            Byte[] encodedBytes_7  = md5_7.ComputeHash(originalBytes_7);
            u8.password   = BitConverter.ToString(encodedBytes_7);
            u8.employeeId = "10024";


            context.users.Add(u);
            context.users.Add(u2);
            context.users.Add(u3);
            context.users.Add(u4);
            context.users.Add(u5);
            context.users.Add(u6);
            context.users.Add(u7);
            context.users.Add(u8);
            context.SaveChanges();


//            Voucher v = new Voucher();
//            v.date = new DateTime(2018, 11, 11, 15, 00, 08);
//            v.itemNumber = "I1001";
//            v.itemName = "test";
//            v.price = 390;
//            v.quantityAdjusted = 13;
//            v.status = "Pending";
//            v.reason = "Missing";
//            context.vouchers.Add(v);
//
//            Voucher v1 = new Voucher();
//            v1.date = new DateTime(2019, 10, 11, 15, 00, 48);
//            v1.itemNumber = "I1002";
//            v.itemName = "test";
//            v1.price = 200;
//            v1.quantityAdjusted = 10;
//            v1.status = "Pending";
//            v1.reason = "i dont know";
//            context.vouchers.Add(v1);


            return(context);
        }