Esempio n. 1
0
 public Undergrad(string first, string last, double gpa, string email, DateTime enrolled,
                  YearRank rank, string major)
     : base(new ContactInfo(first, last, email), gpa, enrolled)
 {
     Rank        = rank;
     DegreeMajor = major;
 }
Esempio n. 2
0
 // the ctor
 // with things that make up a reg student
 // but with the things that make the undergrad student special
 public Undergrad(string first, string last, double gpa,
                  string email, DateTime enrolled,
                  YearRank rank, string degree)
 // needs to lay out the base class first
     : base(new ContactInfo(first, last, email), gpa, enrolled)
 {
     Rank        = rank;
     DegreeMajor = degree;
 }
Esempio n. 3
0
        internal void ReadDataFromInputFile()
        {
            StreamReader infile = new StreamReader(STUDENTDB_DATAFILE);

            string studentType = string.Empty;

            // read the file
            while ((studentType = infile.ReadLine()) != null)
            {
                // read the rest of the record
                string   first = infile.ReadLine();
                string   last  = infile.ReadLine();
                double   gpa   = double.Parse(infile.ReadLine());
                string   email = infile.ReadLine();
                DateTime date  = DateTime.Parse(infile.ReadLine());

                if (studentType == "StudentDB.GradStudent")
                {
                    decimal credit     = decimal.Parse(infile.ReadLine());
                    string  facAdvisor = infile.ReadLine();

                    GradStudent grad = new GradStudent(first, last, gpa, email, date, credit, facAdvisor);
                    students.Add(grad);

                    //Console.WriteLine(grad);
                }
                else if (studentType == "StudentDB.Undergrad")
                {
                    YearRank rank  = (YearRank)Enum.Parse(typeof(YearRank), infile.ReadLine());
                    string   major = infile.ReadLine();

                    Undergrad undergrad = new Undergrad(first, last, gpa, email, date, rank, major);
                    students.Add(undergrad);

                    //Console.WriteLine(undergrad);
                }
                else
                {
                    Console.WriteLine($"ERROR: type {studentType} is not a valid student.");
                }

                // now you have all the data from a single rec - add a new student to the list
                // Student stu = new Student(first, last, gpa, email, date);
                // students.Add(stu);
                // Console.WriteLine(stu);   // as the objects are created, we can monitor the data
            }

            infile.Close();
            Console.WriteLine("Reading input file complete...");
        }
Esempio n. 4
0
        internal void ReadDataFromInputFile()
        {
            // create a stream reader to attach to the input file on disk
            StreamReader infile = new StreamReader("INPUTDATAFILE.txt");

            // use the file to read in student data
            string studentType = string.Empty;

            while ((studentType = infile.ReadLine()) != null)
            {
                // reading the student records
                string   first = infile.ReadLine();
                string   last  = infile.ReadLine();
                double   gpa   = double.Parse(infile.ReadLine());
                string   email = infile.ReadLine();
                DateTime date  = DateTime.Parse(infile.ReadLine());

                // now we've read everything for a student - branch depending
                // on what kind of student
                if (studentType == "StudentDB.Undergrad")
                {
                    YearRank rank  = (YearRank)Enum.Parse(typeof(YearRank), infile.ReadLine());
                    string   major = infile.ReadLine();

                    Undergrad undergrad = new Undergrad(first, last, gpa, email, date, rank, major);
                    students.Add(undergrad); // adding the undergrad to the list

                    // Console.WriteLine(undergrad);
                }
                // if not undergrad, must mean we have a grad student
                else if (studentType == "StudentDB.GradStudent")
                {
                    decimal tuition    = decimal.Parse(infile.ReadLine());
                    string  facAdvisor = infile.ReadLine();

                    GradStudent grad = new GradStudent(first, last, gpa, email, date, tuition, facAdvisor);
                    students.Add(grad);
                }

                // create the new read-in student from the data and store in the list
                //Student stu = new Student(first, last, gpa, email, date);
                //students.Add(stu);
                //Console.WriteLine($"Done reading record for:\n {stu}");
            }

            // release the resource
            Console.WriteLine("Reading input file is complete...");
            infile.Close();
        }
Esempio n. 5
0
        // as stated by the name, this method reads the data from the input file
        // before we had two separate files - INPUTFILE and OUTPUTFILE so we could clearly see
        // what was happenning with the two files and making sure everything was working properly
        // now that we have finished we only have one input and output data file called STUDENTDB_DATAFILE
        internal void ReadDataFromInputFile()
        {
            // StreamReader and StreamWriter = .txt files only
            StreamReader inFile      = new StreamReader(STUDENTDB_DATAFILE);
            string       studentType = string.Empty;

            // keep looping as long as there is something to store in first
            while ((studentType = inFile.ReadLine()) != null)
            {
                // read the rest of the record
                string   first = inFile.ReadLine();
                string   last  = inFile.ReadLine();
                double   gpa   = double.Parse(inFile.ReadLine());
                string   email = inFile.ReadLine();
                DateTime date  = DateTime.Parse(inFile.ReadLine());

                // now we've read everything for a student - branch depending
                // on what kind of student

                if (studentType == "StudentDB.Undergrad")
                {
                    YearRank rank  = (YearRank)Enum.Parse(typeof(YearRank), inFile.ReadLine());
                    string   major = inFile.ReadLine();

                    Undergrad undergrad = new Undergrad(first, last, gpa, email, date, rank, major);
                    students.Add(undergrad);
                }

                else if (studentType == "StudentDB.GradStudent")
                {
                    decimal tuition    = decimal.Parse(inFile.ReadLine());
                    string  facAdvisor = inFile.ReadLine();

                    GradStudent grad = new GradStudent(first, last, gpa, email, date, tuition, facAdvisor);
                    students.Add(grad);
                }

                else
                {
                    Console.WriteLine($"ERROR: type {studentType} is not a valid student.");
                }
            }
            inFile.Close();
            Console.WriteLine("Reading input file complete...");
        }
Esempio n. 6
0
        private void AddStudentRecord()
        {
            //first search the list to see if this email record already exists
            string  email = string.Empty;
            Student stu   = FindStudentRecord(out email);

            if (stu == null)
            {
                //Record was not found - go ahead and add
                //gather all data needed for a new student
                Console.WriteLine($"Adding new student, email: {email}");

                //start gathering data
                //do not need email

                Console.WriteLine("Enter first name: ");
                string first = Console.ReadLine();
                Console.WriteLine("Enter last name: ");
                string last = Console.ReadLine();
                Console.WriteLine("Enter grade point average: ");
                double gpa = double.Parse(Console.ReadLine());

                //find out what kind of student
                Console.WriteLine("[U]ndergrad or [G]rad student? ");
                char studentType = char.Parse(Console.ReadLine().ToUpper());

                //branch based on type of student

                if (studentType == 'U')
                {
                    //reading an enumerated type
                    Console.WriteLine("[1]Freshman, [2]Sophomore, [3]Junior, [4]Senior");
                    Console.Write("Enter year/rank in school from above choices: ");
                    YearRank rank = (YearRank)int.Parse(Console.ReadLine());

                    Console.Write("Enter the major degree program: ");
                    string major = Console.ReadLine();


                    //TODO: test if this use of polymorphism is allowing undergrad info
                    //in the list collection
                    stu = new Undergrad(first, last, gpa, email, DateTime.Now, rank, major);
                    students.Add(stu);
                }
                else if (studentType == 'G')
                {
                    //gather additional grad student info
                    Console.Write("Enter the tuition reimbursement earned (no commas): $");
                    decimal discount = decimal.Parse(Console.ReadLine());
                    Console.Write("Enter full name of graduate faculty advisor: ");
                    string facAdvisor = Console.ReadLine();

                    GradStudent grad = new GradStudent(first, last, gpa, email, DateTime.Now, discount, facAdvisor);
                    students.Add(grad);
                }
                else
                {
                    Console.WriteLine($"ERROR: No student {email} created \n\"{studentType}\" is not valid type.");
                }
            }
            else
            {
                Console.WriteLine($"{email} record is already in the database \nRecord cannot be added.");
                //TODO would you like to update?
            }
        }
Esempio n. 7
0
        private void AddStudentRecord()
        {
            // first, search the list to see if this email rec already exists
            string  email = string.Empty;
            Student stu   = FindStudentRecord(out email);

            if (stu == null)
            {
                // Record was NOT FOUND - go ahead and add
                // first, gather all the data needed for a new student
                Console.WriteLine($"Adding new student, Email: {email}");

                // start gathering data
                Console.Write("ENTER first name: ");
                string first = Console.ReadLine();
                Console.Write("ENTER last name: ");
                string last = Console.ReadLine();
                Console.Write("ENTER grade pt. average: ");
                double gpa = double.Parse(Console.ReadLine());
                // we have the email, obviously!
                // we have to find out what kind of a student? undergrad/grad?
                Console.Write("[U]ndergrad or [G]rad Student? ");
                string studentType = Console.ReadLine().ToUpper();

                // branch out based on what the type of student is
                if (studentType == "U")
                {
                    // reading in an enumnerated type
                    Console.WriteLine("[1]Freshman [2]Sophomore [3]Junior [4]Senior");
                    Console.Write("ENTER year/rank in school from above choices: ");
                    YearRank rank = (YearRank)int.Parse(Console.ReadLine());

                    Console.Write("ENTER major degree program: ");
                    string major = Console.ReadLine();

                    stu = new Undergrad(first, last, gpa, email, DateTime.Now, rank, major);
                    students.Add(stu);
                }
                else if (studentType == "G")
                {
                    // gather additional grad student info
                    Console.Write("ENTER the tuition reimbursement earned (no commas): $");
                    decimal discount = decimal.Parse(Console.ReadLine());
                    Console.Write("ENTER full name of graduate faculty advisor: ");
                    string facAdvisor = Console.ReadLine();

                    GradStudent grad = new GradStudent(first, last, gpa, email, DateTime.Now,
                                                       discount, facAdvisor);

                    students.Add(grad);
                }
                else
                {
                    Console.WriteLine($"ERROR: No student {email} created.\n" +
                                      $"{studentType} is not valid type.");
                }
            }
            else
            {
                Console.WriteLine($"{email} RECORD FOUND! Can't add student {email},\n" +
                                  $"Record already exists.");
            }
        }
Esempio n. 8
0
        // method first makes sure the student doesn't already exist and adds if the stu == null
        // asks for general information then branches off based on what the type of student is
        private void AddStudentRecord()
        {
            // 1. search the list to see if this email record already exists
            string  email = string.Empty;
            Student stu   = FindStudentRecord(out email);

            // record doesn't exist
            if (stu == null)
            {
                // 1. gather all the data needed for a new student
                Console.WriteLine($"Adding a new student, Email: {email}");

                // start gathering data
                Console.Write("Enter first name: ");
                string first = Console.ReadLine();

                Console.Write("Enter last name: ");
                string last = Console.ReadLine();

                // already have the email

                Console.Write("Enter grade pt average: ");
                double gpa = double.Parse(Console.ReadLine());

                // find out what kind of student - undergrad or grad

                Console.Write("[U]ndergrad or [G]rad student? ");
                string studentType = Console.ReadLine().ToUpper();

                // branch out based on what the type of student is
                if (studentType == "U")
                {
                    Console.WriteLine("[1] Freshman, [2] Sophomore, [3] Junior, [4] Senior");
                    Console.Write("Enter the year/rank in school from above choices: ");
                    YearRank rank = (YearRank)int.Parse(Console.ReadLine());

                    Console.Write("Enter major degree program: ");
                    string major = Console.ReadLine();

                    stu = new Undergrad(first, last, gpa, email, DateTime.Now, rank, major);
                    students.Add(stu);
                }

                else if (studentType == "G")
                {
                    // gather additional grad student info
                    Console.Write("Enter the tuition reimbursement earned (no comas): $");
                    decimal discount = decimal.Parse(Console.ReadLine());

                    Console.Write("Enter full name of graduate faculty advisor: ");
                    string facAdvisor = Console.ReadLine();

                    GradStudent grad = new GradStudent(first, last, gpa,
                                                       email, DateTime.Now,
                                                       discount, facAdvisor);
                    students.Add(grad);
                }

                else
                {
                    Console.WriteLine($"ERROR: No student {email} created.\n" +
                                      $"{studentType} is not a valid type");
                }
            }

            // record already exists
            else
            {
                Console.WriteLine($"{email} RECORD FOUND! Can't add student {email},\n" +
                                  $"Record already exists.");
            }
        }
Esempio n. 9
0
        public ActionResult DisplaySearchResults(DateTime?datSelectedDate, String SearchMovieTitle, String SearchTagline,
                                                 int[] SearchGenre, String SelectedYear, MPAArating SelectedMPAARating, String SearchActor, YearRank SelectedSortOrder,
                                                 String StarCount, Option SelectedOption)
        {
            //if they selected a search string, limit results to only repos that meet the criteria
            //create query
            var query = from m in db.Showings
                        select m;

            if (datSelectedDate != null)
            {
                //needed truncate time method because we were comparing a showdate with a specific time compared to one without just a date
                query = query.Where(m => DbFunctions.TruncateTime(m.ShowDate) == datSelectedDate);
            }

            //check to see if they selected something
            if (SearchMovieTitle != null)
            {
                query = query.Where(m => m.SponsoringMovie.MovieTitle.Contains(SearchMovieTitle));
            }

            if (SearchTagline != null)
            {
                query = query.Where(m => m.SponsoringMovie.Tagline.Contains(SearchTagline));
            }

            if (SearchActor != null)
            {
                query = query.Where(m => m.SponsoringMovie.Actor.Contains(SearchActor));
            }

            if (SearchGenre != null)
            {
                foreach (int GenreID in SearchGenre)
                {
                    //Genre GenreToFind = db.Genres.Find(GenreID);
                    query = query.Where(m => m.SponsoringMovie.Genres.Select(g => g.GenreID).Contains(GenreID));
                }
            }

            switch (SelectedMPAARating)
            {
            case MPAArating.G:
                query = query.Where(m => m.SponsoringMovie.MPAAratings == MPAArating.G);
                break;

            case MPAArating.PG:
                query = query.Where(m => m.SponsoringMovie.MPAAratings == MPAArating.PG);
                break;

            case MPAArating.PG13:
                query = query.Where(m => m.SponsoringMovie.MPAAratings == MPAArating.PG13);
                break;

            case MPAArating.R:
                query = query.Where(m => m.SponsoringMovie.MPAAratings == MPAArating.R);
                break;

            case MPAArating.Unrated:
                query = query.Where(m => m.SponsoringMovie.MPAAratings == MPAArating.Unrated);
                break;

            case MPAArating.All:

                break;
            }

            if (SelectedYear != null && SelectedYear != "")
            {
                Int32 intYear;
                try
                {
                    intYear = Convert.ToInt32(SelectedYear);
                }
                catch
                {
                    ViewBag.Message   = SelectedYear + "is not a valid year, please try again!";
                    ViewBag.AllGenres = GetAllGenres();
                    return(View("DetailedSearch"));
                }
                switch (SelectedSortOrder)
                {
                case YearRank.GreaterThan:
                    query = query.Where(r => r.SponsoringMovie.ReleaseDate.Year >= intYear);
                    break;

                case YearRank.LesserThan:
                    query = query.Where(r => r.SponsoringMovie.ReleaseDate.Year <= intYear);
                    break;
                }

                //query = query.Where(m => m.ReleaseDate.Year == intYear);
            }

            if (StarCount != null && StarCount != "")
            {
                Decimal decStar;
                try
                {
                    decStar = Convert.ToDecimal(StarCount);
                }
                catch
                {
                    //not sure which viewbag to put here
                    ViewBag.AllMovies = GetAllMovies();
                    return(View("DetailedSearch"));
                }

                //switch (SelectedOption)
                //{
                //    case Option.GreaterThan:
                //        query = query.Where(r => r.SponsoringMovie.AverageUserRating > decStar);
                //        break;

                //    case Option.LessThan:
                //        query = query.Where(r => r.SponsoringMovie.AverageUserRating <= decStar);
                //        break;
                //}
            }


            List <Showing> SelectedShowings = query.ToList();

            //order list
            SelectedShowings.OrderByDescending(m => m.SponsoringMovie.MovieTitle);

            ViewBag.AllShowings      = db.Showings.Count();
            ViewBag.SelectedShowings = SelectedShowings.Count();
            //send list to view
            return(View("Index", SelectedShowings));
        }
Esempio n. 10
0
 // ctor for manual record creation.
 public Undergrad(string fName, string lName, string email, float gpa, YearRank rank)
     : base(fName, lName, email)
 {
     GradePointAverage = gpa;
     Rank = rank;
 }
Esempio n. 11
0
 // ctor for file input.
 public Undergrad(int id, string fName, string lName, string email, DateTime enroll, float gpa, YearRank rank)
     : base(id, fName, lName, email, enroll)
 {
     GradePointAverage = gpa;
     Rank = rank;
 }
Esempio n. 12
0
        public ActionResult DisplaySearchResults(String SearchMovieTitle, String SearchTagline, int[] SearchGenre, String SelectedYear, MPAArating SelectedMPAARating, String SearchActor, YearRank SelectedSortOrder)
        {
            //if they selected a search string, limit results to only repos that meet the criteria
            //create query
            var query = from m in db.Movies
                        select m;

            //check to see if they selected something
            if (SearchMovieTitle != null)
            {
                query = query.Where(m => m.MovieTitle.Contains(SearchMovieTitle));
            }

            if (SearchTagline != null)
            {
                query = query.Where(m => m.Tagline.Contains(SearchTagline));
            }

            if (SearchActor != null)
            {
                query = query.Where(m => m.Actor.Contains(SearchActor));
            }

            if (SearchGenre != null)
            {
                foreach (int GenreID in SearchGenre)
                {
                    //Genre GenreToFind = db.Genres.Find(GenreID);
                    query = query.Where(m => m.Genres.Select(g => g.GenreID).Contains(GenreID));
                }
            }

            switch (SelectedMPAARating)
            {
            case MPAArating.G:
                query = query.Where(m => m.MPAAratings == MPAArating.G);
                break;

            case MPAArating.PG:
                query = query.Where(m => m.MPAAratings == MPAArating.PG);
                break;

            case MPAArating.PG13:
                query = query.Where(m => m.MPAAratings == MPAArating.PG13);
                break;

            case MPAArating.R:
                query = query.Where(m => m.MPAAratings == MPAArating.R);
                break;

            case MPAArating.Unrated:
                query = query.Where(m => m.MPAAratings == MPAArating.Unrated);
                break;

            case MPAArating.All:

                break;
            }

            if (SelectedYear != null && SelectedYear != "")
            {
                Int32 intYear;
                try
                {
                    intYear = Convert.ToInt32(SelectedYear);
                }
                catch
                {
                    ViewBag.Message   = SelectedYear + "is not a valid year, please try again!";
                    ViewBag.AllGenres = GetAllGenres();
                    return(View("DetailedSearch"));
                }
                switch (SelectedSortOrder)
                {
                case YearRank.GreaterThan:
                    query = query.Where(r => r.ReleaseDate.Year >= intYear);
                    break;

                case YearRank.LesserThan:
                    query = query.Where(r => r.ReleaseDate.Year <= intYear);
                    break;
                }

                //query = query.Where(m => m.ReleaseDate.Year == intYear);
            }

            List <Movie> SelectedMovies = query.ToList();

            //order list
            SelectedMovies.OrderByDescending(m => m.MovieTitle);

            ViewBag.AllMovies      = db.Movies.Count();
            ViewBag.SelectedMovies = SelectedMovies.Count();
            //send list to view
            return(View("Index", SelectedMovies));
        }