public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            var filter = (from st in students
                          where st.MarksPercent > 80
                          select st);
            List <Student> filterStudent = filter.ToList <Student>();

            ViewData["filter"] = filterStudent;

            students.ForEach(student =>
                             student.subjects = Enumerable.Range(0, 4)
                                                .Select((item, i) => $"Subject {item*4+i}").ToList());


            var           many     = students.SelectMany(st => st.subjects);
            List <String> manyList = many.ToList <String>();

            ViewData["many"] = manyList;

            return(View());
        }
Exemplo n.º 2
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            Student first = students.FirstOrDefault();

            ViewData["first"] = first;

            Student last = students.LastOrDefault();

            ViewData["last"] = last;

            Student elementAt = students.ElementAtOrDefault(2);

            ViewData["elementAt"] = elementAt;

            Student single = students.SingleOrDefault(st => st.MarksPercent == 800);

            ViewData["single"] = single;

            List <Student>        emptyList      = new List <Student>();
            IEnumerable <Student> defaultIfEmpty = (IEnumerable <Student>)emptyList.DefaultIfEmpty();

            ViewData["defaultIfEmpty"] = defaultIfEmpty;

            return(View());
        }
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            students.Add(new GradStudent()
            {
                ID           = 100,
                Name         = "Mike",
                MarksPercent = 103
            });
            ViewData["students"] = students;

            var filter = (from st in students
                          where st.MarksPercent > 80
                          select st);
            List <Student> filter1 = filter.ToList <Student>();

            ViewData["filter1"] = filter1;

            filter = (from st in students
                      where st.Name == "June"
                      select st);
            List <Student> filter2 = filter.ToList <Student>();

            ViewData["filter2"] = filter2;

            var gradStudents = students.OfType <GradStudent>().ToList();

            ViewData["gradStudents"] = gradStudents;

            return(View());
        }
Exemplo n.º 4
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            var            take     = students.Take(2);
            List <Student> takeList = take.ToList();

            ViewData["take"] = takeList;

            var            takewhile     = students.OrderBy(st => st.MarksPercent).TakeWhile(st => st.MarksPercent <= 75);
            List <Student> takewhileList = takewhile.ToList();

            ViewData["takewhile"] = takewhileList;

            var            skip     = students.Skip(1);
            List <Student> skipList = skip.ToList();

            ViewData["skip"] = skipList;

            var            skipwhile     = students.OrderBy(st => st.MarksPercent).SkipWhile(st => st.MarksPercent <= 90);
            List <Student> skipwhileList = skipwhile.Reverse().ToList();

            ViewData["skipwhile"] = skipwhileList;


            return(View());
        }
Exemplo n.º 5
0
        public IActionResult Index()
        {
            List <Student> students = studentDAL.GetAllStudents().ToList();
            string         body     = "";

            foreach (Student s in students)
            {
                body += s.FirstName + " | " + s.LastName + " | " + s.NoteFinale + "<br />";
            }

            return(Content(body, "text/html"));
        }
Exemplo n.º 6
0
        public IActionResult StudentListView()
        {
            StudentDAL dal      = new StudentDAL();
            var        students = dal.GetAllStudents();

            ViewData["students"] = students;

            List <Student> toList = students.ToList <Student>();

            ViewData["toList"] = toList;

            Student[] toArray = students.ToArray <Student>();

            ViewData["toArray"] = toArray;

            var            marksLookup = students.ToLookup(st => st.MarksPercent);
            List <Student> listLookup  = new List <Student>();

            foreach (Student s in marksLookup[80])
            {
                listLookup.Add(s);
            }
            ViewData["listLookup"] = listLookup;

            IEnumerable <Student> cast = toList.Cast <Student>();

            ViewData["cast"] = cast;

            ArrayList arrMixed = new ArrayList();

            arrMixed.Add("String value");
            arrMixed.Add(12);
            arrMixed.Add(DateTime.Today);
            arrMixed.Add(students.First());
            IEnumerable <Student> arrOfType  = arrMixed.OfType <Student>();
            List <Student>        ofTypeList = arrOfType.ToList <Student>();

            ViewData["oftypeList"] = ofTypeList;

            IEnumerable <Student> ienum = students.AsEnumerable <Student>();

            ViewData["ienum"] = ienum;

            IQueryable <Student> query = students.AsQueryable().Where(st => st.MarksPercent < 90);

            ViewData["query"] = query;

            var dict = students.ToDictionary(st => st.Name, st => st.Address);

            ViewData["dict"] = dict;
            return(View());
        }
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            var groupby = students.GroupBy(st => st.Class);

            ViewData["groupby"] = groupby;

            return(View());
        }
Exemplo n.º 8
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            var orderby = (from st in students
                           orderby st.Name
                           select st
                           );

            List <Student> orderAsc = orderby.ToList <Student>();

            ViewData["ascorder"] = orderAsc;

            orderby = (from st in students
                       orderby st.Name descending
                       select st
                       );

            List <Student> orderDesc = orderby.ToList <Student>();

            ViewData["descorder"] = orderDesc;

            var            thenBy     = students.OrderBy(st => st.MarksPercent).ThenBy(st => st.Name);
            List <Student> thenByList = thenBy.ToList();

            ViewData["thenbyList"] = thenByList;

            var            thenByDesc     = students.OrderByDescending(st => st.MarksPercent).ThenByDescending(st => st.Name);
            List <Student> thenByDescList = thenByDesc.ToList <Student>();

            ViewData["thenbydescList"] = thenByDescList;


            var reverse = (from st in students
                           orderby st.Name
                           select st
                           ).Reverse();

            List <Student> reverseList = reverse.ToList <Student>();

            ViewData["reverse"] = reverseList;
            return(View());
        }
Exemplo n.º 9
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            students.Add(students[0]);
            ViewData["students"] = students;


            var            students1 = students.Where(st => st.MarksPercent > 90);
            var            students2 = students.Where(st => st.MarksPercent <= 90);
            var            union     = students1.Union(students2);
            List <Student> unionList = union.ToList();

            ViewData["union"] = unionList;

            students1 = students.Where(st => st.MarksPercent >= 80);
            students2 = students.Where(st => st.MarksPercent <= 80);
            var            intersect     = students1.Intersect(students2);
            List <Student> intersectList = intersect.ToList();

            ViewData["intersect"] = intersectList;

            var distinct = (from st in students
                            select new
            {
                st.MarksPercent
            }).Distinct();
            var distinctList = distinct.ToList();

            ViewData["distinct"] = distinctList;


            students1 = students.Where(st => st.MarksPercent >= 80);
            students2 = students.Where(st => st.MarksPercent <= 80);
            var            except     = students1.Except(students2);
            List <Student> exceptList = except.ToList();

            ViewData["except"] = exceptList;
            return(View());
        }
Exemplo n.º 10
0
        public JsonResult <List <Models.Student> > GetAllStudents()
        {
            List <DataModel.Student> dStudents = StudentDAL.GetAllStudents();
            List <Models.Student>    students  = new List <Models.Student>();

            foreach (var item in dStudents)
            {
                Models.Student student = new Models.Student
                {
                    City              = item.City,
                    Class             = item.Class,
                    CountryId         = Convert.ToInt32(item.Country),
                    Email             = item.Email,
                    EnrollYear        = item.EnrollYear,
                    Id                = item.StudentID,
                    Name              = item.Name,
                    AssociatedCountry = CountryDAL.GetCountry(Convert.ToInt32(item.Country))
                };
                students.Add(student);
            }
            return(Json <List <Models.Student> >(students));
        }
Exemplo n.º 11
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            var marksMin = students.Select(student => student.MarksPercent).Min();

            ViewData["minMarks"] = marksMin;

            var marksMax = (from st in students
                            select st.MarksPercent).Max();

            ViewData["maxMarks"] = marksMax;

            var marksTotal = (from st in students
                              select st.MarksPercent).Sum();

            ViewData["sumMarks"] = marksTotal;


            var marksCount = (from st in students
                              select st.MarksPercent).Count();

            ViewData["countMarks"] = marksCount;


            var marksAverage = (from st in students
                                select st.MarksPercent).Average();

            ViewData["averageMarks"] = marksAverage;


            return(View());
        }
Exemplo n.º 12
0
 public List <StudentDTO> GetAllStudents()
 {
     return(StudentDAL.GetAllStudents());
 }
Exemplo n.º 13
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            SubjectDAL     dal2     = new SubjectDAL();
            List <Subject> subjects = (List <Subject>)dal2.GetAllSubjects();

            var innerjoin = (from st in students
                             join sub in subjects on st.ID equals sub.StudentId
                             select new
            {
                st.ID,
                st.Name,
                st.Email,
                st.Address,
                st.Class,
                Subject = sub.Name
            }).ToList();

            ViewData["innerjoin"] = innerjoin;

            var leftjoin = (from st in students
                            join sub in subjects on st.ID equals sub.StudentId
                            into a
                            from b in a.DefaultIfEmpty(new Subject())
                            select new
            {
                st.ID,
                st.Name,
                st.Email,
                st.Address,
                st.Class,
                Subject = b.Name
            }).ToList();

            ViewData["leftjoin"] = leftjoin;

            var crossjoin = (from st in students
                             from sub in subjects
                             select new
            {
                st.ID,
                st.Name,
                st.Email,
                st.Address,
                st.Class,
                Subject = sub.Name
            }).ToList();

            ViewData["crossjoin"] = crossjoin;

            var groupjoin = students.GroupJoin(subjects, st => st.ID, sub => sub.StudentId,
                                               (st, sub) => new { Key = st.ID, Name = st.Name, subjects = sub });

            ViewData["groupjoin"] = groupjoin;


            return(View());
        }
Exemplo n.º 14
0
 public static List<Student> GetAllStudents()
 {
     StudentDAL obj = new StudentDAL();
     return obj.GetAllStudents();
 }
Exemplo n.º 15
0
 public static List<Student> GetAllStudents(string SearchBy, string Search, int page, int pageSize)
 {
     StudentDAL obj = new StudentDAL();
     return obj.GetAllStudents(SearchBy, Search, page, pageSize);
 }
Exemplo n.º 16
0
 public IEnumerable <Students> Index()
 {
     return(obj.GetAllStudents());
 }
Exemplo n.º 17
0
 public static List <Student> GetAllStudents()
 {
     return(StudentDAL.GetAllStudents());
 }
 public List <StudentProfileDTO> GetAllStudents()
 {
     return(studentDAL.GetAllStudents());
 }
 /// <summary>
 /// 获得所有学生信息
 /// </summary>
 /// <returns></returns>
 public List <Student> GetAllStudents()
 {
     return(dal.GetAllStudents());
 }
Exemplo n.º 20
0
        public IActionResult StudentListView()
        {
            StudentDAL     dal      = new StudentDAL();
            List <Student> students = (List <Student>)dal.GetAllStudents();

            ViewData["students"] = students;

            SubjectDAL     dal2     = new SubjectDAL();
            List <Subject> subjects = (List <Subject>)dal2.GetAllSubjects();

            MarksDAL     dal3  = new MarksDAL();
            List <Marks> marks = (List <Marks>)dal3.GetAllMarks();


            var TotalStudent = students.Count();

            ViewData["TotalStudents"] = TotalStudent;

            var TotalSubjects = subjects.Count();

            ViewData["TotalSubjects"] = TotalSubjects;

            //MiniMarks in each Subject
            var innerjoin = (from st in marks
                             join sub in subjects on st.Subject_ID equals sub.ID
                             select new
            {
                Subject = sub.Name,
                Marks = st.Value
            }).ToList();
            var MinMarks = (from ij in innerjoin
                            group ij by ij.Subject into ijGroup
                            select new
            {
                Subject = ijGroup.Key,
                MinMarks = ijGroup.Min(x => x.Marks)
            });

            ViewData["MiniMumMarks"] = MinMarks;

            //MaximumMarks in each Subject

            var MaxMarks = (from ij in innerjoin
                            group ij by ij.Subject into ijGroup
                            select new
            {
                Subject = ijGroup.Key,
                MaxMarks = ijGroup.Max(x => x.Marks)
            });

            ViewData["MaxMarks"] = MaxMarks;

            //Avergae in each Subject

            var AvgMarks = (from ij in innerjoin
                            group ij by ij.Subject into ijGroup
                            select new
            {
                Subject = ijGroup.Key,
                AvgMarks = ijGroup.Average(x => x.Marks)
            });

            ViewData["AvgMarks"] = AvgMarks;



            var crossjoin = (from st in students
                             from sub in subjects

                             select new
            {
                st.ID,
                st.Name,
                st.Email,
                st.Address,
                st.Class,
                Subject = sub.Name,
                Subject_ID = sub.ID
            }).ToList();
            var mark = (from m in marks
                        from cs in crossjoin
                        where m.Student_ID == cs.ID && m.Subject_ID == cs.Subject_ID
                        select new
            {
                cs.ID,
                cs.Name,
                cs.Email,
                cs.Address,
                cs.Class,
                cs.Subject_ID,
                Marks = m.Value,
                cs.Subject
            }

                        ).ToList();

            ViewData["crossjoin"] = mark;


            //Highestmarks

            var stud = from s in mark
                       group s by s.Subject into stugrp
                       let topp = stugrp.Max(x => x.Marks)
                                  select new
            {
                Subject      = stugrp.Key,
                TopStudent   = stugrp.First(y => y.Marks == topp).ID,
                MaximumMarks = topp
            }
            ;

            var HighestMarks = (from h in mark
                                from st in stud
                                where h.ID == st.TopStudent && h.Subject == st.Subject
                                select new
            {
                Name = h.Name,
                Email = h.Email,
                Address = h.Address,
                Subject = st.Subject,
                Marks = st.MaximumMarks
            }).ToList();

            ViewData["HighestMarks"] = HighestMarks;

            //Lowest Marks
            var Loweststud = from s in mark
                             group s by s.Subject into Loweststudgrp
                             let low = Loweststudgrp.Min(x => x.Marks)
                                       select new
            {
                Subject     = Loweststudgrp.Key,
                TopStudent  = Loweststudgrp.First(y => y.Marks == low).ID,
                LowestMarks = low
            }
            ;

            var lowestMarks = (from h in mark
                               from st in Loweststud
                               where h.ID == st.TopStudent && h.Subject == st.Subject
                               select new
            {
                Name = h.Name,
                Email = h.Email,
                Address = h.Address,
                Subject = st.Subject,
                Marks = st.LowestMarks
            }).ToList();

            ViewData["lowestMarks"] = lowestMarks;



            return(View());
        }