コード例 #1
0
        public static void UpdateStudentTeamsRecords()
        {
            using (var context = new EFIADBContext()) {
                var steams = context.StudentTeams.ToList();
                foreach (StudentTeams st in steams)
                {
                    Console.WriteLine(st);
                }

                Console.Write("Enter the StudentID number in the record you wish to update: ");
                var userStudentNum = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the TeamID number in the record you wish to update: ");
                var userTeamNum = Convert.ToInt32(Console.ReadLine());

                var findSteam = steams.Where(co => co.StudentID == userStudentNum && co.TeamID == userTeamNum);
                foreach (StudentTeams co in findSteam)
                {
                    Console.WriteLine($"The StudentID and TeamID record you wish to update is: {co.StudentID} and {co.TeamID}");
                    Console.Write("Enter the StudentID number in the record you wish to update the record to: ");
                    var userStudentNumUpdate = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter the TeamID number in the record you wish to update the record to: ");
                    var userTeamNumUpdate = Convert.ToInt32(Console.ReadLine());
                    co.StudentID = userStudentNumUpdate;
                    co.TeamID    = userTeamNumUpdate;
                    Console.WriteLine($"The StudentID and TeamID updated record is: {co.StudentID} and {co.TeamID}");
                }
                context.SaveChanges();
            }
        }
コード例 #2
0
        public static void CreateFaculty()
        {
            Console.Write("Faculty members's first name: ");
            string f_fName = Console.ReadLine();

            Console.Write("Faculty members's last name: ");
            string f_lName = Console.ReadLine();

            Console.Write("Faculty members's phone number: ");
            string f_phoneNumber = Console.ReadLine();

            Console.Write("Faculty members's email: ");
            string f_email = Console.ReadLine();

            Console.Write("Faculty members's department: ");
            string f_department = Console.ReadLine();

            using (var context = new EFIADBContext()) {
                List <FacultySponsor> sponsors = new List <FacultySponsor>()
                {
                    new FacultySponsor()
                    {
                        FirstName      = f_fName,
                        LastName       = f_lName,
                        PhoneNumber    = f_phoneNumber,
                        Email          = f_email,
                        DepartmentName = f_department
                    }
                };
                context.FacultySponsor.AddRange(sponsors);
                context.SaveChanges();
            }
            Console.WriteLine("Faculty member record added.");
        }
コード例 #3
0
        public static void UpdateClientOrganizationRecords()
        {
            using (var context = new EFIADBContext()) {
                var corgs = context.ClientOrganization.ToList();
                foreach (ClientOrganization c in corgs)
                {
                    Console.WriteLine(c);
                }

                Console.Write("Enter the ClientID number in the record you wish to update: ");
                var userClientNum = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the OrganizationID number in the record you wish to update: ");
                var userOrgNum = Convert.ToInt32(Console.ReadLine());

                var findCorg = corgs.Where(co => co.ClientID == userClientNum && co.OrganizationID == userOrgNum);
                foreach (ClientOrganization co in findCorg)
                {
                    Console.WriteLine($"The ClientID and OrganizationID record you wish to update is: {co.ClientID} and {co.OrganizationID}");
                    Console.Write("Enter the ClientID number in the record you wish to update the record to: ");
                    var userClientNumUpdate = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter the OrganizationID number in the record you wish to update the record to: ");
                    var userOrgNumUpdate = Convert.ToInt32(Console.ReadLine());
                    co.ClientID       = userClientNumUpdate;
                    co.OrganizationID = userOrgNumUpdate;
                    Console.WriteLine($"The ClientID and OrganizationID updated record is: {co.ClientID} and {co.OrganizationID}");
                }
                context.SaveChanges();
            }
        }
コード例 #4
0
        public static void CreateClient()
        {
            Console.Write("Client's first name: ");
            string c_fName = Console.ReadLine();

            Console.Write("Client's last name: ");
            string c_lName = Console.ReadLine();

            Console.Write("Client's phone number: ");
            string c_phoneNumber = Console.ReadLine();

            Console.Write("Client's email: ");
            string c_email = Console.ReadLine();

            Console.Write("Client's company ID: ");
            int c_company = Convert.ToInt32(Console.ReadLine());

            using (var context = new EFIADBContext()) {
                List <Client> clients = new List <Client>()
                {
                    new Client()
                    {
                        FirstName      = c_fName,
                        LastName       = c_lName,
                        PhoneNumber    = c_phoneNumber,
                        Email          = c_email,
                        OrganizationID = c_company
                    }
                };
                context.Client.AddRange(clients);
                context.SaveChanges();
            }
            Console.WriteLine("Client record added.");
        }
コード例 #5
0
        public static void CreateStudent()
        {
            Console.Write("Student's first name: ");
            string s_fName = Console.ReadLine();

            Console.Write("Student's last name: ");
            string s_lName = Console.ReadLine();

            Console.Write("Student's phone number: ");
            string s_phoneNumber = Console.ReadLine();

            Console.Write("Student's email: ");
            string s_email = Console.ReadLine();

            Console.Write("Student's major: ");
            string s_major = Console.ReadLine();

            using (var context = new EFIADBContext()) {
                List <Student> students = new List <Student>()
                {
                    new Student()
                    {
                        FirstName   = s_fName,
                        LastName    = s_lName,
                        PhoneNumber = s_phoneNumber,
                        Email       = s_email,
                        Major       = s_major
                    }
                };
                context.Student.AddRange(students);
                context.SaveChanges();
            }
            Console.WriteLine("Student record added.");
        }
コード例 #6
0
 public static void ReadAllOrganizationRecords()
 {
     using (var context = new EFIADBContext()) {
         var orgs = context.Organization.ToList();
         foreach (Organization o in orgs)
         {
             Console.WriteLine(o);
         }
     }
 }
コード例 #7
0
 public static void ReadAllStudentRecords()
 {
     using (var context = new EFIADBContext()) {
         var students = context.Student.ToList();
         foreach (Student s in students)
         {
             Console.WriteLine(s);
         }
     }
 }
コード例 #8
0
 public static void ReadAllClientRecords()
 {
     using (var context = new EFIADBContext()) {
         var clients = context.Client.ToList();
         foreach (Client c in clients)
         {
             Console.WriteLine(c);
         }
     }
 }
コード例 #9
0
 public static void ReadAllTeamRecords()
 {
     using (var context = new EFIADBContext()) {
         var teams = context.Team.ToList();
         foreach (Team c in teams)
         {
             Console.WriteLine(c);
         }
     }
 }
コード例 #10
0
 public static void ReadAllFacultyRecords()
 {
     using (var context = new EFIADBContext()) {
         if (context.Client.Any())
         {
             var facultySponsors = context.FacultySponsor.ToList();
             foreach (FacultySponsor f in facultySponsors)
             {
                 Console.WriteLine(f);
             }
         }
     }
 }
コード例 #11
0
        public static void CreateOrganization()
        {
            Console.Write("Organization name: ");
            string orgName = Console.ReadLine();

            Console.Write("Organization phone number: ");
            string o_phoneNumber = Console.ReadLine();

            Console.Write("Organization email: ");
            string o_email = Console.ReadLine();

            Console.Write("Organization address (line 1): ");
            string o_addLine1 = Console.ReadLine();

            Console.Write("Organization address (line 2): ");
            string o_addLine2 = Console.ReadLine();

            Console.Write("Organization address city: ");
            string o_city = Console.ReadLine();

            Console.Write("Organization address zipcode: ");
            string o_zipcode = Console.ReadLine();

            Console.Write("Organization address state: ");
            string o_state = Console.ReadLine();

            using (var context = new EFIADBContext()) {
                List <Organization> org = new List <Organization>()
                {
                    new Organization()
                    {
                        OrganizationName = orgName,
                        PhoneNumber      = o_phoneNumber,
                        Email            = o_email,
                        AddLine1         = o_addLine1,
                        AddLine2         = o_addLine2,
                        City             = o_city,
                        Zipcode          = o_zipcode,
                        State            = o_state
                    }
                };
                context.Organization.AddRange(org);
                context.SaveChanges();
            }
            Console.WriteLine("Team record added.");
        }
コード例 #12
0
        public static void CreateTeam()
        {
            Console.Write("Team name: ");
            string teamName = Console.ReadLine();

            using (var context = new EFIADBContext()) {
                List <Team> teams = new List <Team>()
                {
                    new Team()
                    {
                        TeamName = teamName
                    }
                };
                context.Team.AddRange(teams);
                context.SaveChanges();
            }
            Console.WriteLine("Team record added.");
        }
コード例 #13
0
        public static void FindTeamRecord()
        {
            Console.WriteLine("Sorry! This function isn't ready yet!");
            Console.Write("Enter team name, know that it must be an exact match: ");
            string findTeam = Console.ReadLine();

            using (var context = new EFIADBContext())
            {
                var teams = context.Team.ToList();
                foreach (Team t in teams)
                {
                    if (t.TeamName == findTeam)
                    {
                        Console.WriteLine("Team found.");
                        Console.WriteLine("Deleting team...");
                        //Insert code here to delete the record
                        Console.WriteLine("Team deleted.");
                    }
                }
            }
        }
コード例 #14
0
        public static void CreateSeedData()
        {
            //This opens then closes the connection to the DB, helps security
            using (var context = new EFIADBContext()) {
                //Take this out later - this is deleting the db file
                //context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
            }

            using (var context = new EFIADBContext()) {
                //Creating the list of test student teams
                if (!context.StudentTeams.Any())
                {
                    Console.WriteLine("Checking if database exists......");
                    Console.WriteLine("It does not.");
                    Console.WriteLine("Creating database...seeding database...");
                    List <StudentTeams> steams = new List <StudentTeams>()
                    {
                        new StudentTeams()
                        {
                            StudentID = 1,
                            TeamID    = 1,
                            Role      = "Front End Developer"
                        },
                        new StudentTeams()
                        {
                            StudentID = 2,
                            TeamID    = 1,
                            Role      = "Coder"
                        }
                    };
                    context.StudentTeams.AddRange(steams);
                    context.SaveChanges();
                }
                //Creating the list of test student teams
                if (!context.ClientOrganization.Any())
                {
                    List <ClientOrganization> corgs = new List <ClientOrganization>()
                    {
                        new ClientOrganization()
                        {
                            ClientID       = 1,
                            OrganizationID = 1,
                        },
                        new ClientOrganization()
                        {
                            ClientID       = 2,
                            OrganizationID = 1,
                        }
                    };
                    context.ClientOrganization.AddRange(corgs);
                    context.SaveChanges();
                }
                //Creating the list of test students
                if (!context.Student.Any())
                {
                    List <Student> students = new List <Student>()
                    {
                        new Student()
                        {
                            FirstName   = "Mara",
                            LastName    = "Kinoff",
                            PhoneNumber = "XXX-XXX-XXXX",
                            Email       = "*****@*****.**",
                            Major       = "CIS"
                        },
                        new Student()
                        {
                            FirstName   = "Sean",
                            LastName    = "Kinoff",
                            PhoneNumber = "XXX-XXX-XXXX",
                            Email       = "*****@*****.**",
                            Major       = "CIS"
                        }
                    };
                    context.Student.AddRange(students);
                    context.SaveChanges();
                }

                //Creating the list of test clients
                if (!context.Client.Any())
                {
                    List <Client> clients = new List <Client>()
                    {
                        new Client()
                        {
                            FirstName      = "John",
                            LastName       = "Smith",
                            PhoneNumber    = "XXX-XXX-XXXX",
                            Email          = "*****@*****.**",
                            OrganizationID = 1
                        },
                        new Client()
                        {
                            FirstName      = "Jane",
                            LastName       = "Smith",
                            PhoneNumber    = "XXX-XXX-XXXX",
                            Email          = "*****@*****.**",
                            OrganizationID = 2
                        }
                    };
                    context.Client.AddRange(clients);
                    context.SaveChanges();
                }

                //Creating the list of test faculty
                if (!context.FacultySponsor.Any())
                {
                    List <FacultySponsor> facultySponsors = new List <FacultySponsor>()
                    {
                        new FacultySponsor()
                        {
                            FirstName      = "Jeff",
                            LastName       = "Babb",
                            PhoneNumber    = "XXX-XXX-XXXX",
                            Email          = "*****@*****.**",
                            DepartmentName = "Computer Information and Decision Management"
                        },
                        new FacultySponsor()
                        {
                            FirstName      = "Katherine",
                            LastName       = "Payne",
                            PhoneNumber    = "XXX-XXX-XXXX",
                            Email          = "*****@*****.**",
                            DepartmentName = "Computer Information and Decision Management"
                        }
                    };
                    context.FacultySponsor.AddRange(facultySponsors);
                    context.SaveChanges();
                }

                //Creating the list of test teams
                if (!context.Team.Any())
                {
                    List <Team> teams = new List <Team>()
                    {
                        new Team()
                        {
                            TeamName = "Team Alpha"
                        },
                        new Team()
                        {
                            TeamName = "Team Beta"
                        }
                    };
                    context.Team.AddRange(teams);
                    context.SaveChanges();
                }
                //Creating list of organizations
                if (!context.Organization.Any())
                {
                    List <Organization> org = new List <Organization>()
                    {
                        new Organization()
                        {
                            OrganizationName = "A Company",
                            PhoneNumber      = "012-345-6789",
                            Email            = "*****@*****.**",
                            AddLine1         = "123 West Ave",
                            AddLine2         = "Suite 101",
                            City             = "Amarillo",
                            Zipcode          = "77777",
                            State            = "TX"
                        },
                        new Organization()
                        {
                            OrganizationName = "B Company",
                            PhoneNumber      = "122-333-4444",
                            Email            = "*****@*****.**",
                            AddLine1         = "123 East Ave",
                            AddLine2         = "",
                            City             = "Amarillo",
                            Zipcode          = "77777",
                            State            = "TX"
                        }
                    };
                    context.Organization.AddRange(org);
                    context.SaveChanges();
                }
            }
        }