static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students grouped by GROUP NUMBER using LINQ!");
        var groupedByGroupNumber =
            from student in students
            orderby student.GroupNumber
            select student;

        foreach (var st in groupedByGroupNumber)
        {
            Console.WriteLine("Name: {0} {1}, Group number: {2}",
                              st.FirstName,
                              st.LastName,
                              st.GroupNumber);
        }

        Console.WriteLine("\nStudents grouped by GROUP NUMBER using LINQ with extension method!");
        var groupedByGroupNumberWithExtension = students.OrderBy(x => x.GroupNumber);


        foreach (var st in groupedByGroupNumberWithExtension)
        {
            Console.WriteLine("Name: {0} {1}, Group number: {2}",
                              st.FirstName,
                              st.LastName,
                              st.GroupNumber);
        }
    }
Exemple #2
0
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students from GROUP 2!");
        var studentsFromSecondGroup = students.Where(st => st.GroupNumber == 2);

        foreach (var st in studentsFromSecondGroup)
        {
            Console.WriteLine("Name: {0} {1}, Group Nr.: {2}",
                              st.FirstName,
                              st.LastName,
                              st.GroupNumber);
        }

        Console.WriteLine("\nStudents from GROUP 2 ordered by first name!");
        var studentsFromSecondGroupOrderedByFirstName = studentsFromSecondGroup.OrderBy(st => st.FirstName);

        foreach (var st in studentsFromSecondGroupOrderedByFirstName)
        {
            Console.WriteLine("Name: {0} {1}, Group Nr.: {2}",
                              st.FirstName,
                              st.LastName,
                              st.GroupNumber);
        }
    }
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students from GROUP 2!");
        var studentsFromSecondGroup =
            from student in students
            where student.GroupNumber == 2
            select student;

        foreach (var st in studentsFromSecondGroup)
        {
            Console.WriteLine("Name: {0} {1}, Group Nr.: {2}",
                              st.FirstName,
                              st.LastName,
                              st.GroupNumber);
        }

        Console.WriteLine("\nStudents from GROUP 2 ordered by first name!");
        var studentsFromSecondGroupOrderedByFirstName =
            from student in studentsFromSecondGroup
            orderby student.FirstName
            select student;

        foreach (var st in studentsFromSecondGroupOrderedByFirstName)
        {
            Console.WriteLine("Name: {0} {1}, Group Nr.: {2}",
                              st.FirstName,
                              st.LastName,
                              st.GroupNumber);
        }
    }
    static void Main()
    {
        Student[] students          = ListOfStudents.GetListOfSudents().ToArray();
        var       studentInAgeRange = FindStudentsInAgeRange(students, 18, 24);

        foreach (var st in studentInAgeRange)
        {
            Console.WriteLine("Name: {0} {1}, Age: {2}", st.FirstName, st.LastName, st.Age);
        }
    }
Exemple #5
0
 private static ListOfStudents GetAddNewStudent(ListOfStudents listOfStudents, int numberOfStudents)
 {
     for (int i = 1; i <= numberOfStudents; i++)
     {
         List <string> student    = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
         var           parceGrade = float.Parse(student[2]);
         Student       newStudent = new Student(student[0], student[1], parceGrade);
         listOfStudents.FirstListOfStudents.Add(newStudent);
     }
     return(listOfStudents);
 }
Exemple #6
0
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students with exact two marks 2!");
        var studentsWithTwoMarks = students.Where(st => st.Marks.FindAll(x => x == 2).Count == 2);

        foreach (var st in studentsWithTwoMarks)
        {
            Console.WriteLine("Name: {0} {1}", st.FirstName, st.LastName);
        }
    }
Exemple #7
0
        static void Main(string[] args)
        {
            int numberOfStudents = int.Parse(Console.ReadLine());

            ListOfStudents listOfStudents = new ListOfStudents();

            listOfStudents = GetAddNewStudent(listOfStudents, numberOfStudents);

            foreach (var student in listOfStudents.FirstListOfStudents.OrderByDescending(x => x.Grade))
            {
                Console.WriteLine(student.ToString());
            }
        }
 public void UpdateStudentList(Student newStudent)
 {
     IsEmpty    = false;
     IsNotEmpty = true;
     if (!string.IsNullOrEmpty(newStudent.StudentName))
     {
         ListOfStudents.Add(newStudent);
     }
     else
     {
         Application.Current.MainPage.DisplayAlert("Alert!", "Student name is missing.Please try again.", "OK");
     }
 }
        private void GetAllStudents()
        {
            var allStudents = DatabaseHelper.GetInstance().GetStudentsForClass(_studentClass.ClassId);

            if (allStudents != null && allStudents.Count > 0)
            {
                IsEmpty    = false;
                IsNotEmpty = true;
                foreach (var student in allStudents)
                {
                    ListOfStudents.Add(student);
                }
            }
        }
Exemple #10
0
    static void Main()
    {
        List <Group> groups = new List <Group>()
        {
            new Group {
                GroupNumber    = 1,
                DepartmentName = "Mathematics"
            },
            new Group {
                GroupNumber    = 2,
                DepartmentName = "Phisics"
            },
            new Group {
                GroupNumber    = 3,
                DepartmentName = "Computer Science"
            }
        };

        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students from the Mathematics department:");

        var studentsFromMathDepartment =
            from gr in groups
            where gr.DepartmentName == "Mathematics"
            join student in students
            on gr.GroupNumber
            equals student.GroupNumber
            select new
        {
            FullName       = string.Format("{0} {1}", student.FirstName, student.LastName),
            DepartmentName = gr.DepartmentName
        };

        foreach (var st in studentsFromMathDepartment)
        {
            Console.WriteLine("Name: {0}\n--->Department: {1}\n", st.FullName, st.DepartmentName);
        }


        //var studentsFromMathDepartment =
        //    from student in students
        //    where student.GroupNumber == 1
        //    join gr in groups
        //    //where gr.DepartmentName == "Mathematics"
        //    on student.GroupNumber
        //    equals gr.GroupNumber
        //    select student;
    }
        private void AddAttendee()
        {
            bool IsInList = false;

            if (SelectedStudent != null)
            {
                if ((ListOfStudents.Count == 0) && (AleadyInvitedStudents.Count == 0))
                {
                    ListOfStudents.Add(SelectedStudent);
                }
                else
                {
                    foreach (var s in ListOfStudents)
                    {
                        if (s == SelectedStudent)
                        {
                            IsInList = true;
                        }
                        else if (s != SelectedStudent)
                        {
                            continue;
                        }
                    }
                    foreach (var t in AleadyInvitedStudents)
                    {
                        if (t == SelectedStudent)
                        {
                            IsInList = true;
                        }
                        else if (t != SelectedStudent)
                        {
                            continue;
                        }
                    }

                    if (IsInList == true)
                    {
                        MessageDialog msg = new MessageDialog("This student is already added as attendee.");
                        msg.ShowAsync();
                    }
                    else
                    {
                        ListOfStudents.Add(SelectedStudent);
                    }
                }
            }
        }
 public void DeleteStudent(string studentId)
 {
     try{
         DatabaseHelper.GetInstance().DeleteStudent(studentId);
         for (int i = 0; i < ListOfStudents.Count; i++)
         {
             if (studentId.Equals(ListOfStudents[i].StudentId))
             {
                 ListOfStudents.RemoveAt(i);
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK");
     }
 }
Exemple #13
0
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students that have email in ABV!");

        var emailInAbv =
            from student in students
            where student.Email.Contains("abv.bg")
            select student;

        foreach (var st in emailInAbv)
        {
            Console.WriteLine("Name: {0} {1}, Email: {2}",
                              st.FirstName,
                              st.LastName,
                              st.Email);
        }
    }
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Using Lambda Method");
        var studentsOrderedLambda = OrderStudentsDescendingLambda(students);

        foreach (var student in studentsOrderedLambda)
        {
            Console.WriteLine("Name: {0} {1}", student.FirstName, student.LastName);
        }

        Console.WriteLine("\nUsing LINQ Method");
        var studentsOrderedLinq = OrderStudentsDescendingLinq(students);

        foreach (var student in studentsOrderedLinq)
        {
            Console.WriteLine("Name: {0} {1}", student.FirstName, student.LastName);
        }
    }
Exemple #15
0
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students with phone in Sofia!");

        var phoneInSofia =
            from student in students
            where student.PhoneNumber.StartsWith("02") ||
            student.PhoneNumber.StartsWith("+359 2") ||
            student.PhoneNumber.StartsWith("00359 2")
            select student;

        foreach (var st in phoneInSofia)
        {
            Console.WriteLine("Name: {0} {1}, Phone number: {2}",
                              st.FirstName,
                              st.LastName,
                              st.PhoneNumber);
        }
    }
    static void Main()
    {
        //List<Student> students = ListOfStudents.GetListOfSudents();
        Student[] students = ListOfStudents.GetListOfSudents().ToArray();

        Console.WriteLine("Lambda method:");
        var studentsListLambda = FirstBeforeLastLambda(students);

        foreach (var st in studentsListLambda)
        {
            Console.WriteLine("Name: {0} {1}", st.FirstName, st.LastName);
        }

        Console.WriteLine("Linq method:");
        var studentsListLinq = FirstBeforeLastLinq(students);

        foreach (var st in studentsListLinq)
        {
            Console.WriteLine("Name: {0} {1}", st.FirstName, st.LastName);
        }
    }
Exemple #17
0
    static void Main()
    {
        List <Student> students       = ListOfStudents.GetListOfSudents();
        var            studentsIn2006 =
            from student in students
            where student.FN.ToString().EndsWith("06")
            select new
        {
            Fullname = string.Format("{0} {1}", student.FirstName, student.LastName),
            Marks    = student.Marks
        };

        foreach (var st in studentsIn2006)
        {
            Console.Write("\nName: {0}\n Marks: ",
                          st.Fullname);
            foreach (var mark in st.Marks)
            {
                Console.Write(" ({0}) ", mark);
            }
        }
    }
    static void Main()
    {
        List <Student> students = ListOfStudents.GetListOfSudents();

        Console.WriteLine("Students that have at least one mark Excellent (6)!");

        var studentsWithExcellentMark =
            from student in students
            where student.Marks.Contains(6)
            select new
        {
            FullName = string.Format("{0} {1}", student.FirstName, student.LastName),
            Marks    = student.Marks
        };

        foreach (var st in studentsWithExcellentMark)
        {
            Console.WriteLine("\nName: {0}", st.FullName);
            foreach (var mark in st.Marks)
            {
                Console.Write(" ({0}) ", mark);
            }
        }
    }
Exemple #19
0
 public void RemoveStudent(Student s)
 {
     ListOfStudents.Remove(s);
 }
Exemple #20
0
 public void addStudents(Student student)
 {
     ListOfStudents.Add(student);
 }
        public IActionResult SaveTeacherRegistration(TeacherRegistrationVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View("TeacherRegistration", TeacherInput(model)));
            }

            var contact = new ContactInfo()
            {
                Email   = model.Email,
                Phone   = model.PhoneNummber,
                Address = model.Address
            };

            db.Contact.Add(contact);
            db.SaveChanges();

            var profileInfo = new ProfileInfo()
            {
                Username     = model.Username,
                PasswordSalt = PasswordHashAndSalt.GenerateSalt()
            };

            profileInfo.PasswordHash = PasswordHashAndSalt.GenerateHash(profileInfo.PasswordSalt, model.Password);

            db.ProfileInfo.Add(profileInfo);
            db.SaveChanges();

            var newTutor = new TutorRegistrationForm()
            {
                FName         = model.FName,
                LName         = model.LName,
                ProfileInfoId = profileInfo.Id,
                DateOfBirth   = model.DateOfBirth,
                CollageName   = model.CollageName,
                Price         = model.Price,
                TitleId       = model.TitleId,
                SubjectId     = model.SubjectId,
                ContactInfoId = contact.Id,
                CityId        = model.CityId,
                GenderId      = model.GenderId,
                IsRead        = false
            };



            if (model.ProfilePicture != null)
            {
                var fileExst     = Path.GetExtension(model.ProfilePicture.FileName);
                var newFileName  = Convert.ToString(Guid.NewGuid()) + fileExst;
                var fileName     = Path.Combine(hostingEnvironment.WebRootPath, "Profilepictures") + $@"\{newFileName}";
                var databaseName = "/Profilepictures/" + newFileName;
                model.ProfilePicture.CopyTo(new FileStream(fileName, FileMode.Create));
                newTutor.ProfilePicture = databaseName;
            }

            db.TutorRegistrationForm.Add(newTutor);
            db.SaveChanges();

            foreach (var item in model.typeOfStudents)
            {
                if (item.Checked)
                {
                    var PerferedType = new ListOfStudents()
                    {
                        TutorRegistrationFormId = newTutor.Id,
                        StudentTypeId           = item.StudentTypeId
                    };

                    db.ListOfStudents.Add(PerferedType);
                    db.SaveChanges();
                }
            }

            foreach (var item in model.Proof)
            {
                var fileExst    = Path.GetExtension(item.FileName);
                var newFileName = Convert.ToString(Guid.NewGuid()) + fileExst;
                var fileName    = Path.Combine(hostingEnvironment.WebRootPath, "ProofPictures") + $@"\{newFileName}";
                item.CopyTo(new FileStream(fileName, FileMode.Create));
                var databaseName = "/ProofPictures/" + newFileName;

                var proofPicture = new Proof()
                {
                    TutorRegistrationFormId = newTutor.Id,
                    PictureName             = databaseName
                };

                db.Proof.Add(proofPicture);
            }
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #22
0
 public void AddStudent(Student s)
 {
     ListOfStudents.Add(s);
 }