コード例 #1
0
ファイル: TestingSULS.cs プロジェクト: mkmirchev/OOP
        internal static void Main()
        {
            //testing SoftUni's learning system
            //testing students
            CurrentStudent crntStudent = new CurrentStudent("Ivan", "Ivanich", 25, 12478, 5.32, "OOP");
            Console.WriteLine(crntStudent);
            Console.WriteLine();
            DropoutStudent drpStudent = new DropoutStudent("Prekusnal", "Student", 21, 12202, 3.03, "Murzi me");
            drpStudent.ReApply();
            Console.WriteLine();
            GraduatedStudent gradStudent = new GraduatedStudent("Evgeni", "Minchev", 35, 22471, 5.92);
            Console.WriteLine(gradStudent);
            Console.WriteLine();

            OnlineStudent onlnStd = new OnlineStudent("Mircho", "Mirchev", 27, 65234, 5.47, "OOP");
            Console.WriteLine(onlnStd);
            Console.WriteLine();
            OnsiteStudent onstStd = new OnsiteStudent("Stef", "Andres", 23, 52416, 4.99, 4, "HQC");
            Console.WriteLine(onstStd);
            Console.WriteLine();

            //testing trainers
            JuniorTrainer jun = new JuniorTrainer("Fil", "Kolev", 32);
            Console.WriteLine(jun);
            jun.CreateCourse("OOP");
            jun.CreateCourse("HQC");
            Console.WriteLine();

            SeniorTrainer sen = new SeniorTrainer("Svetlin", "Nakov", 41);
            Console.WriteLine(sen);
            sen.CreateCourse("Data bases");
            sen.CreateCourse("ASP.Net MCV basics");
            sen.DeleteCourse("OOP");
        }
コード例 #2
0
        static void Main()
        {
            List <Person> persons = new List <Person>();

            persons.Add(new SeniorTrainer("Mihail", "Draganov", 42));
            persons.Add(new OnsiteStudent("Georgi", "Peikov", 25, 4367743, 5.20, "Advanced C#", 2));
            persons.Add(new OnlineStudent("Georgi", "Peikov", 25, 4367743, 5.20, "Advanced Back-End"));
            persons.Add(new SeniorTrainer("Sonya", "Petkova", 48));
            persons.Add(new JuniorTrainer("Sonya", "Petkova", 48));
            persons.Add(new JuniorTrainer("Galq", "Vazova", 39));
            persons.Add(new GraduateStudent("Ivan", "Tsankov", 23, 5356672, 4.95));
            persons.Add(new CurrentStudent("Katerina", "Mileva", 19, 4536545, 5.78, "Java Fundamentals"));
            persons.Add(new DropoutStudent("Pesho", "Goshev", 21, 543536, 3.65, "Presence drunk on lectures."));
            persons.Add(new SeniorTrainer("Pencho", "Vasilev", 48));
            persons.Add(new OnsiteStudent("Vankata", "Draganov", 24, 4235436, 5.00, "Advanced C#", 5));
            persons.Add(new OnlineStudent("Stoqn", "Ivanov", 19, 547452654, 4.70, "Advanced Back-End"));
            persons.Add(new SeniorTrainer("Mihaila", "Dimitrova", 38));
            persons.Add(new JuniorTrainer("Ivaila", "Hristova", 43));
            persons.Add(new JuniorTrainer("Filip", "Ignatov", 36));
            persons.Add(new GraduateStudent("Tihomir", "Georgiev", 25, 2376535, 4.56));
            persons.Add(new CurrentStudent("Dimitar", "Conev", 23, 465256, 5.23, "Java Fundamentals"));
            persons.Add(new DropoutStudent("Ivan", "Petrov", 25, 765344, 5.65, "Killed an inocent student."));

            var currentStudentsOnly = persons.Where(x => x.GetType() == typeof(CurrentStudent));

            foreach (var student in currentStudentsOnly)
            {
                CurrentStudent st = (CurrentStudent)student;
                Console.WriteLine(st.ToString());
                Console.WriteLine("Student number: {0}\nAverage Grade: {1}\n", st.StudentNumber, st.AverageGrade);
            }
        }
コード例 #3
0
        public ActionResult CheckLogInInfo(Student s)
        {
            if (s.Email == "Admin" && s.Password == "1234")
            {
                return(RedirectToAction("AdminPage", "Admin"));
            }
            try
            {
                if (DataConnection.CheckLogInInfo(s) == true)
                {
                    CurrentStudent.GetInstance().InitializeStudent(s);

                    return(RedirectToAction("StudentPage", "Register"));
                }
                else
                {
                    Global.currentError = Global.Errors.invalidLogIn;
                    return(RedirectToAction("LogIn", "LogIn"));
                }
            }
            catch (SqlException e)
            {
                Global.currentError = Global.Errors.coundNotConnectToDatabase;
                return(RedirectToAction("LogIn", "LogIn"));
            }
        }
コード例 #4
0
 private void StudentChecker()
 {
     if (CurrentStudent.Age <= 7)
     {
         MessageBox.Show("Student is Underage!");
     }
     else
     {
         if (SelectedStudent == null)
         {
             SaveStudent();
         }
         else
         {
             if (CurrentStudent.Equals(SelectedStudent))
             {
                 MessageBox.Show("Updated");
             }
             else
             {
                 UpdateStudent();
             }
         }
         SelectedStudent = null;
         CurrentStudent  = null;
         SV.Close();
     }
 }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
        public ActionResult ReadPost(int Id)
        {
            Post           post           = StudentNewsDb.Posts.Find(Id);
            CurrentStudent currentStudent = StudentNewsDb.CurrentStudent.First();
            Student        student        = StudentNewsDb.Students.Where(s => (s.FirstName == currentStudent.FirstName && s.LastName == currentStudent.LastName)).FirstOrDefault();

            return(View(Tuple.Create(student, post)));
        }
コード例 #6
0
 private void DeleteStudent()
 {
     if (CurrentStudent != null)
     {
         context.Delete(CurrentStudent.Model());
         Students.Remove(CurrentStudent);
         CurrentStudent = null;
     }
 }
コード例 #7
0
 public ActionResult DropStudentFromCourse(CourseRegistration r)
 {
     if (r.CourseToAlter >= 0)
     {
         CurrentStudent.GetInstance().RemoveCourse(r.CourseToAlter);
     }
     Global.lastpartialView = "DropCourse";
     return(RedirectToAction("StudentPage", "Register"));
 }
コード例 #8
0
        public PartialViewResult DropCourse()
        {
            CourseRegistration r = new CourseRegistration();

            r.student          = new Student(CurrentStudent.GetInstance().FirstName, CurrentStudent.GetInstance().LastName, CurrentStudent.GetInstance().Password, CurrentStudent.GetInstance().Email, CurrentStudent.GetInstance().ID, CurrentStudent.GetInstance().major);
            r.student.schedule = CurrentStudent.GetInstance().GetSchedule();
            foreach (var item in r.student.schedule)
            {
                r.isDropped.Add(item.Value.ID, false);
            }
            return(PartialView(r));
        }
コード例 #9
0
        public PartialViewResult ViewSchedule()
        {
            Student s = new Student();

            s.FirstName            = CurrentStudent.GetInstance().FirstName;
            s.LastName             = CurrentStudent.GetInstance().LastName;
            s.Email                = CurrentStudent.GetInstance().Email;
            s.Password             = CurrentStudent.GetInstance().Password;
            s.major                = CurrentStudent.GetInstance().major;
            s.schedule             = (CurrentStudent.GetInstance().GetSchedule());
            Global.lastpartialView = "ViewSchedule";
            return(PartialView(s));
        }
コード例 #10
0
        public PartialViewResult StudentInfo()
        {
            Student s = new Student();

            s.FirstName = CurrentStudent.GetInstance().FirstName;
            s.LastName  = CurrentStudent.GetInstance().LastName;
            s.Email     = CurrentStudent.GetInstance().Email;
            s.Password  = CurrentStudent.GetInstance().Password;
            s.major     = CurrentStudent.GetInstance().major;
            s.schedule  = (CurrentStudent.GetInstance().GetSchedule());
            s.CalculateCredits();
            return(PartialView(s));
        }
コード例 #11
0
 public ActionResult UpdateStudentInfo(Student s)
 {
     CurrentStudent.GetInstance().Email     = s.Email;
     CurrentStudent.GetInstance().Password  = s.Password;
     CurrentStudent.GetInstance().FirstName = s.FirstName;
     CurrentStudent.GetInstance().LastName  = s.LastName;
     s.ID       = CurrentStudent.GetInstance().ID;
     s.major    = CurrentStudent.GetInstance().major;
     s.schedule = (CurrentStudent.GetInstance().GetSchedule());
     DataConnection.UpdateStudent(CurrentStudent.GetInstance().ID, s);
     Global.lastpartialView = "StudentInfo";
     return(RedirectToAction("StudentPage", "Register"));
 }
コード例 #12
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
        public ActionResult DeletePost(int Id)
        {
            Post           post           = StudentNewsDb.Posts.Find(Id);
            CurrentStudent currentStudent = StudentNewsDb.CurrentStudent.First();
            Student        student        = StudentNewsDb.Students.Where(s => (s.FirstName == currentStudent.FirstName && s.LastName == currentStudent.LastName)).FirstOrDefault();

            if (post.StudentId != student.Id)
            {
                return(View("EditDeleteErrorView"));
            }
            StudentNewsDb.Posts.Remove(post);
            StudentNewsDb.SaveChanges();
            return(RedirectToAction("NewsListForm", student));
        }
コード例 #13
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
        public ActionResult AddComment(string CommentText, int Id)
        {
            CurrentStudent currentStudent = StudentNewsDb.CurrentStudent.First();
            Student        student        = StudentNewsDb.Students.Where(s => (s.FirstName == currentStudent.FirstName && s.LastName == currentStudent.LastName)).FirstOrDefault();
            Comment        newComment     = new Comment();

            newComment.Content        = CommentText;
            newComment.PostId         = Id;
            newComment.Post           = StudentNewsDb.Posts.Find(Id);
            newComment.AuthorId       = student.Id;
            newComment.DateOfCreation = DateTime.Now;
            StudentNewsDb.Comments.Add(newComment);
            StudentNewsDb.SaveChanges();
            return(View());
        }
コード例 #14
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
        public ActionResult Edit(int Id)
        {
            Post           post           = StudentNewsDb.Posts.Find(Id);
            CurrentStudent currentStudent = StudentNewsDb.CurrentStudent.First();
            Student        student        = StudentNewsDb.Students.Where(s => (s.FirstName == currentStudent.FirstName && s.LastName == currentStudent.LastName)).FirstOrDefault();

            if (post.StudentId != student.Id)
            {
                return(View("EditDeleteErrorView"));
            }
            StringBuilder tagStr = new StringBuilder();

            foreach (var tag in post.Tags)
            {
                tagStr.AppendFormat("#" + tag.Name);
            }
            TempData["TagStr"] = tagStr;
            return(View(Tuple.Create(student, post)));
        }
コード例 #15
0
        public ActionResult RegisterCourse(CourseRegistration r)
        {
            Course tempCourse = DataConnection.getCourse(r.CourseToAlter);

            if (CurrentStudent.GetInstance().CheckForOverlap(tempCourse))
            {
                Global.currentError = Global.Errors.timeOverlap;
            }
            else
            {
                if (Global.currentError != Global.Errors.fullschedule)
                {
                    Global.currentError = "";
                }
                CurrentStudent.GetInstance().AddCourse(tempCourse);
            }
            Global.lastpartialView = "AddCourse";
            return(RedirectToAction("StudentPage", "Register"));
        }
コード例 #16
0
        public PartialViewResult AddCourse()
        {
            CourseRegistration r = new CourseRegistration();

            r.student          = new Student(CurrentStudent.GetInstance().FirstName, CurrentStudent.GetInstance().LastName, CurrentStudent.GetInstance().Password, CurrentStudent.GetInstance().Email, CurrentStudent.GetInstance().ID, CurrentStudent.GetInstance().major);
            r.student.schedule = CurrentStudent.GetInstance().GetSchedule();
            r.student.CalculateCredits();
            if (r.student.isFull)
            {
                Global.currentError = Global.Errors.fullschedule;
            }
            else if (Global.currentError != Global.Errors.timeOverlap)
            {
                Global.currentError = "";
            }
            r.courses = DataConnection.getAllCourses();

            return(PartialView(r));
        }
コード例 #17
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
        public ActionResult EditPost(int Id, string Description, string Content, string TagsStr)
        {
            Post post = StudentNewsDb.Posts.Find(Id);

            post.Description = Description;
            post.Content     = Content;
            String[] TagsStringArray = TagsStr.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
            post.Tags.Clear();
            foreach (var tagName in TagsStringArray)
            {
                post.Tags.Add(new Tag {
                    Name = tagName
                });
            }
            StudentNewsDb.SaveChanges();
            CurrentStudent currentStudent = StudentNewsDb.CurrentStudent.First();
            Student        student        = StudentNewsDb.Students.Where(s => (s.FirstName == currentStudent.FirstName && s.LastName == currentStudent.LastName)).FirstOrDefault();

            return(RedirectToAction("NewsListForm", student));
        }
コード例 #18
0
ファイル: SULStest.cs プロジェクト: IliyaBoyanov/OOP
 static void Main()
 {
     List<object> list = new List<object>();
     Person stamat = new Person("Stamat", "Stamtov", 18);
     Trainer vladi = new Trainer("Vladi", "Vargala", 24);
     SeniorTrainer nakov = new SeniorTrainer("Svetin", "Nakov", 22);
     JuniorTrainer niki = new JuniorTrainer("Nikolay", "Bankin", 18);
     niki.CreateCourse("Tvardost na betona");
     nakov.DeleteCourse("Tvardost na betona");
     Student mimi = new Student("Mariya", "Ilieva", 25, 1345, 4.60);
     DropoutStudent vasko = new DropoutStudent("Vasko", "Keca", 17, 300, 5, "Music");
     vasko.Reapply();
     GraduateStudent nobody = new GraduateStudent("Misho", "Birata", 40, 20, 3.40);
     OnlineStudent uncleTony = new OnlineStudent("Uncle", "Antony", 25, 7, 5, "OOP");
     CurrentStudent me = new CurrentStudent("Gosho", "Lyaskov", 28, 1, 5.4, "OOP");
     CurrentStudent you = new CurrentStudent("Pesho", "Peshev", 28, 2, 5.1, "OOP");
     CurrentStudent somebody = new CurrentStudent("Uncnown", "Person", 14, 190, 6, "OOP");
     AddtoList(list, stamat, vladi, nakov, niki, mimi, vasko, nobody, uncleTony, me, you, somebody);
     list.Where(x => x is CurrentStudent).OrderByDescending(x => ((Student)x).StudentAverageGrade).ToList().ForEach(x => Console.WriteLine(x.ToString()));
 }
コード例 #19
0
ファイル: SULSTest.cs プロジェクト: alvelchev/SoftUni
        static void Main()
        {
            var nasko = new Trainer("Atanas", "Rusenov", 21);
            var fill = new JuniorTrainer("Filip", "Kolev", 28);
            var nakov = new SeniorTrainer("Svetlin", "Nakov", 60);

            var mark = new GraduateStudent("Марк", "Зукърбъргов", 38, 120511, 6.00);
            var mitio = new DropoutStudent("Митьо", "Крика", 40, 343535, 2.30, "Много големи ръки");
            var djordjano = new CurrentStudent("Djordjano", "Djordjankata", 25, 0888155,"Introducing to singing");
            var baiVulcho = new OnlineStudent("Бай", "Вълчо", 73, 4444, 5.60,"OOP");
            var lelqVanche = new OnsiteStudent("Леля", "Ванче", 57, 12034, 4.89, "Аdvanced C#", 20);

            nakov.DeleteCourse("PHP");
            fill.CreateCourse("Advanced C#");
            nasko.CreateCourse("Kopane");
            nakov.DeleteCourse("Kopane"); // Nasko, what are you doing?!?
            Console.WriteLine();

            var persons = new List<Person>()
            {
                nasko,
                fill,
                nakov,
                mark,
                mitio,
                djordjano,
                baiVulcho,
                lelqVanche
            };

            var currentStudents = persons.Where(student => student is CurrentStudent)
                .OrderBy(student => ((Student)student).AverageGrade)
                .Select(student => student);

            foreach (var currentStudent in currentStudents)
            {
                Console.WriteLine(currentStudent);
            }
        }
コード例 #20
0
ファイル: SULSTest.cs プロジェクト: DiyanTonchev/SoftUni
        static void Main()
        {
            var nasko = new Trainer("Atanas", "Rusenov", 21);
            var fill  = new JuniorTrainer("Filip", "Kolev", 28);
            var nakov = new SeniorTrainer("Svetlin", "Nakov", 60);

            var mark       = new GraduateStudent("Марк", "Зукърбъргов", 38, 120511, 6.00);
            var mitio      = new DropoutStudent("Митьо", "Крика", 40, 343535, 2.30, "Много големи ръки");
            var djordjano  = new CurrentStudent("Djordjano", "Djordjankata", 25, 0888155, "Introducing to singing");
            var baiVulcho  = new OnlineStudent("Бай", "Вълчо", 73, 4444, 5.60, "OOP");
            var lelqVanche = new OnsiteStudent("Леля", "Ванче", 57, 12034, 4.89, "Аdvanced C#", 20);

            nakov.DeleteCourse("PHP");
            fill.CreateCourse("Advanced C#");
            nasko.CreateCourse("Kopane");
            nakov.DeleteCourse("Kopane"); // Nasko, what are you doing?!?
            Console.WriteLine();

            var persons = new List <Person>()
            {
                nasko,
                fill,
                nakov,
                mark,
                mitio,
                djordjano,
                baiVulcho,
                lelqVanche
            };

            var currentStudents = persons.Where(student => student is CurrentStudent)
                                  .OrderBy(student => ((Student)student).AverageGrade)
                                  .Select(student => student);

            foreach (var currentStudent in currentStudents)
            {
                Console.WriteLine(currentStudent);
            }
        }
コード例 #21
0
        public async Task <ActionResult> Confirmation(string ButtonType)
        {
            if (ButtonType == "Next")
            {
                ApplicationDbContext context = new ApplicationDbContext();

                var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

                var user = new ApplicationUser {
                    UserName = CurrentUserModel.Username, Email = CurrentUserModel.Email, DisplayName = CurrentStudent.Parents.First().Parent.GetFullName()
                };


                var result = await UserManager.CreateAsync(user, CurrentUserModel.Password);

                if (result.Succeeded)
                {
                    UserManager.AddToRole(user.Id, "Parent");
                    CurrentStudent.Parents.First().Parent.user_id = user.Id;

                    ApplicationSignInManager SignInManager = HttpContext.GetOwinContext().Get <ApplicationSignInManager>();
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);



                    CurrentStudent.Languages.Clear();

                    foreach (string lan_id in StudentExtraInfoModel.Languages)
                    {
                        CurrentStudent.Languages.Add(_unitOfWork.Languages.Find(lan_id));
                    }

                    if (CurrentAppID != null)
                    {
                        Entity.Application app = _unitOfWork.Applications.Find(CurrentAppID);
                        app.app_status = BLL.Constants.ApplicationStatuses.ADMITED;
                        _unitOfWork.Applications.Update(app);
                        CurrentStudent.Applications.Add(app);
                    }



                    _unitOfWork.Students.Add(CurrentStudent);

                    try
                    {
                        await _unitOfWork.SaveAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                    }



                    return(View("FinishAdmission", new Models.Admission.SuccessAdmissionViewModel()
                    {
                        Email = user.Email,
                        UserName = user.UserName,
                        StudentFullName = CurrentStudent.GetFullName(),
                        ParentFullName = CurrentStudent.Parents.First().Parent.GetFullName(),
                        Relation = CurrentStudent.Parents.First().Relation
                    }));
                }
            }


            else if (ButtonType == "Back")
            {
                return(View("UserRegistration", CurrentUserModel));
            }



            return(View());
        }
コード例 #22
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
 public ActionResult CreateNewPostForm(CurrentStudent currentStudent)
 {
     return(View(currentStudent));
 }
コード例 #23
0
ファイル: HomeController.cs プロジェクト: 487549alex/test
        public ActionResult CreateNewPost(string Description, string Content, string TagsStr, CurrentStudent currentStudent)
        {
            Post    newPost = new Post();
            Student student = StudentNewsDb.Students.Where(s => (s.FirstName == currentStudent.FirstName && s.LastName == currentStudent.LastName)).FirstOrDefault();

            newPost.Student        = student;
            newPost.StudentId      = student.Id;
            newPost.Description    = Description;
            newPost.Content        = Content;
            newPost.DateOfCreation = DateTime.Now;

            String[] TagsStringArray = TagsStr.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var tagName in TagsStringArray)
            {
                newPost.Tags.Add(new Tag {
                    Name = tagName
                });
            }
            StudentNewsDb.Posts.Add(newPost);
            StudentNewsDb.SaveChanges();
            return(RedirectToAction("NewsListForm", student));
        }
コード例 #24
0
    static void Main()
    {
        List <Person> softUniPeople  = new List <Person>();
        string        checker        = null;
        uint          studentNumber  = 0u;
        float         averageGrade   = 0f;
        string        currentCourse  = null;
        uint          numberOfVisits = 0u;
        string        dropoutReason  = null;

        do
        {
            Person temp;
            Console.WriteLine("Please choose a type of object:");
            Console.WriteLine("1 - Person");
            Console.WriteLine("2 - Trainer");
            Console.WriteLine("3 - Junior Trainer");
            Console.WriteLine("4 - Senior Trainer");
            Console.WriteLine("5 - Student");
            Console.WriteLine("6 - GraduateStudent");
            Console.WriteLine("7 - CurrentStudent");
            Console.WriteLine("8 - Online Student");
            Console.WriteLine("9 - Onsite Student");
            Console.WriteLine("10 - Dropout Student");
            byte typeOfObject = byte.Parse(Console.ReadLine());
            Console.WriteLine("Please enter a first name:");
            string firstName = Console.ReadLine();
            Console.WriteLine("Please enter a last name:");
            string lastName = Console.ReadLine();
            Console.WriteLine("Please enter an age:");
            int age = int.Parse(Console.ReadLine());
            if (typeOfObject >= 5)
            {
                Console.WriteLine("Please enter a student number:");
                studentNumber = uint.Parse(Console.ReadLine());
                Console.WriteLine("Please enter an average grade:");
                averageGrade = float.Parse(Console.ReadLine());
                if (typeOfObject >= 7 && typeOfObject <= 9)
                {
                    Console.WriteLine("Please enter student current course:");
                    currentCourse = Console.ReadLine();
                    if (typeOfObject == 9)
                    {
                        Console.WriteLine("Please enter a numebr of visits:");
                        numberOfVisits = uint.Parse(Console.ReadLine());
                    }
                }
                else if (typeOfObject == 10)
                {
                    Console.WriteLine("Please enter dropout reason");
                    dropoutReason = Console.ReadLine();
                }
            }
            switch (typeOfObject)
            {
            case (1): temp = new Person(firstName, lastName, age); break;

            case (2): temp = new Trainer(firstName, lastName, age); break;

            case (3): temp = new JuniorTrainer(firstName, lastName, age); break;

            case (4): temp = new SeniorTrainer(firstName, lastName, age); break;

            case (5): temp = new Student(firstName, lastName, age, studentNumber, averageGrade); break;

            case (6): temp = new GraduateStudent(firstName, lastName, age, studentNumber, averageGrade); break;

            case (7): temp = new CurrentStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse); break;

            case (8): temp = new OnlineStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse); break;

            case (9): temp = new OnsiteStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse, numberOfVisits); break;

            case (10): temp = new DropoutStudent(firstName, lastName, age, studentNumber, averageGrade, dropoutReason); break;

            default:
                Console.WriteLine("Invalid object type");
                continue;
            }

            Console.WriteLine("Would you like to print the current object? Y\\N");
            checker = Console.ReadLine();
            if (checker == "Y" || checker == "y")
            {
                Console.WriteLine(temp.ToString());
            }
            if (typeOfObject >= 2 && typeOfObject <= 4)
            {
                Console.WriteLine("Would you like to add a course? Y\\N");
                checker = Console.ReadLine();
                if (checker == "Y" || checker == "y")
                {
                    Console.WriteLine("Please enter a course name:");
                    string  course      = Console.ReadLine();
                    Trainer tempTrainer = (Trainer)temp;
                    tempTrainer.CreateCourse(course);
                }
                if (typeOfObject == 4)
                {
                    Console.WriteLine("Would you like to delete a course? Y\\N");
                    checker = Console.ReadLine();
                    if (checker == "Y" || checker == "y")
                    {
                        Console.WriteLine("Please enter a course name:");
                        string        course      = Console.ReadLine();
                        SeniorTrainer tempTrainer = (SeniorTrainer)temp;
                        tempTrainer.DeleteCourse(course);
                    }
                }
            }
            if (typeOfObject == 10)
            {
                Console.WriteLine("Would you like to reapply? Y\\N");
                checker = Console.ReadLine();
                if (checker == "Y" || checker == "y")
                {
                    DropoutStudent tempStudent = (DropoutStudent)temp;
                    tempStudent.Reapply();
                }
            }
            softUniPeople.Add(temp);
            Console.WriteLine("Would you like to add another object? Y\\N");
            checker = Console.ReadLine();
        } while (checker != "N" && checker != "n");

        softUniPeople.Where(p => p is CurrentStudent).OrderBy(p => ((CurrentStudent)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString()));
    }
コード例 #25
0
 protected virtual void GetStudentSession(CurrentStudentConnectedEventArgs e)
 {
     CurrentStudent?.Invoke(this, e);
 }
コード例 #26
0
 public ViewResult LogIn()
 {
     CurrentStudent.GetInstance().ResetCurrentStudent();
     return(View());
 }
コード例 #27
0
ファイル: SULSTest.cs プロジェクト: AsenTahchiyski/SoftUni
        static void Main()
        {
            Person person1 = new Person("Gosho", "Minchev", 66);
            Person person2 = new Person("Pesho", "Genchev", 26);
            Person person3 = new Person("Mityo", "Pishtovliev", 36);
            List<Person> persons = new List<Person> { person1, person2, person3 };

            Student student1 = new Student("Misho", "Goranov", 23, "90012315", 4.56);
            Student student2 = new Student("Maya", "Petrova", 28, "90013315", 5.50);
            Student student3 = new Student("Petya", "Svilenova", 23, "90023315", 5.76);
            List<Student> students = new List<Student> { student1, student2, student3 };

            Trainer trainer1 = new Trainer("Svetlin", "Nakov", 33);
            Trainer trainer2 = new Trainer("Preslav", "Nakov", 35);
            Trainer trainer3 = new Trainer("Mario", "Peshev", 31);
            List<Trainer> trainers = new List<Trainer> { trainer1, trainer2, trainer3 };

            JuniorTrainer junior1 = new JuniorTrainer("Fil", "Kolev", 29);
            JuniorTrainer junior2 = new JuniorTrainer("Penka", "Borukova", 28);
            JuniorTrainer junior3 = new JuniorTrainer("Ivo", "Kotow", 30);
            List<JuniorTrainer> juniorTrainers = new List<JuniorTrainer> { junior1, junior2, junior3 };

            SeniorTrainer senior1 = new SeniorTrainer("Angel", "Georgiev", 31);
            SeniorTrainer senior2 = new SeniorTrainer("Atanas", "Rusenov", 26);
            SeniorTrainer senior3 = new SeniorTrainer("Bogomil", "Dimitrov", 30);
            List<SeniorTrainer> seniorTrainers = new List<SeniorTrainer> { senior1, senior2, senior3 };

            CurrentStudent currentSt1 = new CurrentStudent("Georgi", "Petkov", 21, "900432114", 5.25, "Advanced JavaScript");
            CurrentStudent currentSt2 = new CurrentStudent("Aneliya", "Borisova", 20, "900422114", 4.56, "Java Basics");
            CurrentStudent currentSt3 = new CurrentStudent("Sasha", "Grey", 29, "900434315", 3.69, "Avanced C#");
            List<CurrentStudent> currentStudents = new List<CurrentStudent> { currentSt1, currentSt2, currentSt3 };

            CurrentOnlineStudent currOnlineSt1 = new CurrentOnlineStudent("Merry", "Poppins", 22, "900682115", 3.50, "OOP");
            CurrentOnlineStudent currOnlineSt2 = new CurrentOnlineStudent("Aaron", "Turner", 32, "900542115", 5.50, "Database Applications");
            CurrentOnlineStudent currOnlineSt3 = new CurrentOnlineStudent("Nashmat", "Kodarov", 22, "900684315", 5.24, "Web Fundamentals");
            List<CurrentOnlineStudent> currentOnlineStudents = new List<CurrentOnlineStudent> { currOnlineSt1, currOnlineSt2, currOnlineSt3 };

            CurrentOnsiteStudent currOnsiteSt1 = new CurrentOnsiteStudent("Masha", "Medvedevna", 18, "900543215", 4.15, "Java Basics");
            CurrentOnsiteStudent currOnsiteSt2 = new CurrentOnsiteStudent("Ivana", "Kotareva", 29, "900693215", 5.80, "Java Advanced");
            CurrentOnsiteStudent currOnsiteSt3 = new CurrentOnsiteStudent("Ismail", "Programoglu", 18, "900541115", 4.95, "C# Advanced");
            List<CurrentOnsiteStudent> currentOnsiteStudents = new List<CurrentOnsiteStudent> { currOnsiteSt1, currOnsiteSt2, currOnsiteSt3 };

            GraduateStudent gradStudent1 = new GraduateStudent("Koycho", "Nashmatov", 25, "900122114", 5.15);
            GraduateStudent gradStudent2 = new GraduateStudent("Katya", "Yavorova", 45, "900002114", 5.45);
            GraduateStudent gradStudent3 = new GraduateStudent("Gospodin", "Nashmatov", 26, "900122214", 5.59);
            List<GraduateStudent> graduateStudents = new List<GraduateStudent> { gradStudent1, gradStudent2, gradStudent3 };

            DropoutStudent dropStudent1 = new DropoutStudent("Ganka", "Prostakieva", 19, "9001235214", 2.85, "Low grades");
            DropoutStudent dropStudent2 = new DropoutStudent("Vasil", "Sarikov", 29, "9001015214", 2.40, "Low grades");
            DropoutStudent dropStudent3 = new DropoutStudent("Daniel", "Zarezliev", 19, "9001235214", 4.85, "Going to the Mars colony.");
            List<DropoutStudent> dropoutStudents = new List<DropoutStudent> { dropStudent1, dropStudent2, dropStudent3 };

            List<Person> database = new List<Person>();
            database.AddRange(persons);
            database.AddRange(students);
            database.AddRange(trainers);
            database.AddRange(juniorTrainers);
            database.AddRange(seniorTrainers);
            database.AddRange(currentStudents);
            database.AddRange(currentOnlineStudents);
            database.AddRange(currentOnsiteStudents);
            database.AddRange(graduateStudents);
            database.AddRange(dropoutStudents);

            var currentStudentsSortedByAvgGrade = database.Where(x => x is CurrentStudent).Cast<CurrentStudent>().OrderByDescending(x => x.AverageGrade);

            foreach (Student student in currentStudentsSortedByAvgGrade)
            {
                Console.WriteLine("Name: {0} {1}", student.FirstName, student.LastName);
                Console.WriteLine("Average Grade: {0}", student.AverageGrade);
            }
        }