Example #1
0
        public IActionResult ListStudents()
        {
            List <Student> Allstudents = studentRepository.GetAllStudents().ToList();

            var model = new List <StudentIndexViewModel>();

            foreach (var student in Allstudents)
            {
                StudentIndexViewModel studentIndexViewModel = new StudentIndexViewModel()
                {
                    StudentId  = student.StudentId,
                    Fname      = student.Fname,
                    Lname      = student.Lname,
                    Email      = student.Email,
                    Level      = student.Level.LevelName.ToString(),
                    Department = student.Department.DepartmentName.ToString(),
                    PhotoPath  = student.PhotoPath
                };

                studentIndexViewModel.Courses = studentRepository.GetStudentCourses(student.StudentId).ToList();

                model.Add(studentIndexViewModel);
            }

            return(View(model));
        }
        // GET: Students
        public async Task <IActionResult> Index(string studentIndex, string studentFullName)
        {
            IQueryable <Student> students = _context.Student.AsQueryable();

            //IQueryable<string> indexQuery = (IQueryable<string>)_context.Student.OrderBy(m => m.StudentId).Select(m => m.StudentId).Distinct();
            //IQueryable<string> fullnameQuery = (IQueryable<string>)_context.Student.OrderBy(m => m.FullName).Select(m => m.FullName).Distinct();

            if (!string.IsNullOrEmpty(studentIndex))
            {
                students = students.Where(s => s.StudentId.Contains(studentIndex));
            }

            if (!string.IsNullOrEmpty(studentFullName))
            {
                students = students.Where(x => x.FullName == studentFullName);
            }

            //students = students.Include(m => m.FirstTeacher).Include(m => m.SecondTeacher);

            var studentIndexVM = new StudentIndexViewModel
            {
                Students = await students.ToListAsync()
            };

            return(View(studentIndexVM));
            //var workShop1Context = _context.Course.Include(c => c.FirstTeacher).Include(c => c.SecondTeacher);
            //return View(await workShop1Context.ToListAsync());
        }
        public async Task <StudentIndexViewModel> GetStudents(int pageIndex, int itemsPage, string searchFilter, int?departmentId)
        {
            _logger.LogInformation("GetStudents is called");

            var studentsInfo = await _studentRepository.ListAsync(new StudentFilterSpecification(searchFilter, departmentId));

            var departments = await _departmentRepository.ListAllAsync();

            var studentVM = new StudentIndexViewModel()
            {
                Students = studentsInfo.Select(s => new StudentViewModel()
                {
                    DateOfBirth    = s.DateOfBirth,
                    DepartmentId   = s.DepartmentId,
                    DepartmentName = departments.FirstOrDefault(d => d.Id == s.DepartmentId).Name,
                    Email          = s.Email,
                    FullName       = string.Format("{0}{1} {2}", s.FirstName, string.IsNullOrWhiteSpace(s.MiddleName) ? string.Empty : " " + s.MiddleName, s.LastName),
                    FirstName      = s.FirstName,
                    LastName       = s.LastName,
                    StudentId      = s.Id,
                    StudentNumber  = s.StudentNumber,
                    Gender         = Enum.GetName(typeof(GenderValues), s.Gender)
                }),

                DepartmentFilterApplied = departmentId ?? 0,
                SearchFilter            = string.IsNullOrWhiteSpace(searchFilter)?string.Empty:searchFilter,
                Departments             = await GetDepartments(),
                GenderTypes             = GetGender()
            };

            return(studentVM);
        }
        public IActionResult Index()
        {
            var student = new StudentIndexViewModel();

            student.listStudent = _repositoryStudent.GetAllStudent();

            student.CurrentMensage = "Student";
            return(View(student));
        }
Example #5
0
        public async Task <IActionResult> Index()
        {
            var studentIndexViewModel = new StudentIndexViewModel
            {
                WelcomeMessage = Resource.Welcome
            };

            return(View(studentIndexViewModel));
        }
Example #6
0
        public ActionResult Index()
        {
            StudentIndexViewModel sivm = new StudentIndexViewModel
            {
                Students          = studentsRepository.All.ToList(),
                CompetencyHeaders = competenciesHeadersRepository.All.ToList()
            };

            return(View(sivm));
        }
        public async Task <IActionResult> IndexStudent()
        {
            string userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            StudentIndexViewModel model = new StudentIndexViewModel();
            var user = await this.userManager.GetUserAsync(this.User);

            model.ApplicationUser = this.mapper.Map <ApplicationUser, BaseApplicationUserVM>(user, model.ApplicationUser);
            model.Student         = this.usersService.GetStudentByUserId <BaseStudentVM>(userId);
            return(this.View(model));
        }
Example #8
0
        public IActionResult Index()
        {
            string id = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            StudentIndexViewModel students = new StudentIndexViewModel();

            students.students   = _context.Students.Where(x => x.UserId == id).ToList();
            students.classrooms = _context.Classrooms.Where(x => x.Id == students.students[0].ClassroomId).ToList();

            //List<Students> student = _context.Students.Where(x => x.UserId == id).ToList();

            return(View(students));
        }
Example #9
0
        //public StudentController(UnitOfWork uow)
        //{
        //    _uow = uow;
        //}
        // GET: Student
        public ActionResult Index()
        {
            var students = _uow.Students.GetAll();



            //var students = new StudentRepository(new SampleDbContext()).GetAll();////_uow.Students.GetAll();//.GetAllStudents();
            //var students = new MockStudentRepository().GetAll();
            StudentIndexViewModel svm = new StudentIndexViewModel();

            svm.Students = students.ToList();
            return(View(svm));
        }
Example #10
0
        public ActionResult Alerts()
        {
            //
            DateTime start = DateTime.Today,
                     end   = start.AddDays(7);

            var viewModel = new StudentIndexViewModel()
            {
                //select only events within 7 days of current date
                AlertList = _db.Events.Where(d => d.StartDate > start && d.StartDate < end)
            };

            return(View(viewModel));
        }
Example #11
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            classRoom = await _context.ClassRooms.Where(d => d.Id == id).Select(d => new StudentIndexViewModel
            {
                className = d.ClassName,
                id        = d.Id,
                students  = d.Students.ToList()
            }).AsNoTracking().FirstOrDefaultAsync();

            if (classRoom == null)
            {
                return(NotFound());
            }



            return(Page());
        }
        public ActionResult Edit(StudentIndexViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var student = db.Students.FirstOrDefault(s => s.Id == vm.Id);

                if (student != null)
                {
                    student.FirstName      = vm.FirstName;
                    student.LastName       = vm.LastName;
                    student.EnrollmentDate = vm.EnrollmentDate;
                }

                db.Entry(student).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(vm));
        }
Example #13
0
        // GET: Students
        public ActionResult Index(int?selectedClassId = null)
        {
            ViewBag.Title = "My Students";
            var items = new List <SelectListItem>();

            items.Add(new SelectListItem {
                Text = string.Empty, Value = "0"
            });
            items.AddRange(DataRepository.GetTeachersClasses(SessionItems.TeacherId.Value).
                           Where(x => x.Active).
                           Select(s => new SelectListItem {
                Text = s.ClassName, Value = s.Id.ToString(), Selected = (selectedClassId.HasValue && s.Id == selectedClassId.Value)
            }).OrderBy(x => x.Text));
            var model = new StudentIndexViewModel
            {
                SelectedClassId = selectedClassId,
                Classes         = items.ToList()
            };

            return(View(model));
        }
Example #14
0
        // GET: Student Index
        public ActionResult Index()
        {
            StudentBusinessLayer            studentBusinessLayer        = new StudentBusinessLayer();
            StudentIndexViewModel           studentIndexModel           = new StudentIndexViewModel();
            List <StudentsDetailsViewModel> studentDetailsViewModelList = new List <StudentsDetailsViewModel>();

            foreach (StudentDetails studentDetails in studentBusinessLayer.studentListWithDetails)
            {
                studentDetailsViewModelList.Add(new StudentsDetailsViewModel());
                studentDetailsViewModelList.Last().Id        = studentDetails.Id;
                studentDetailsViewModelList.Last().FirstName = studentDetails.FirstName;
                studentDetailsViewModelList.Last().LastName  = studentDetails.LastName;

                foreach (string strStudentEmail in studentDetails.studentEmails)
                {
                    studentDetailsViewModelList.Last().studentEmails.Add(strStudentEmail);
                }
            }
            studentIndexModel.viewStudentListWithDetails = studentDetailsViewModelList;
            return(View(studentIndexModel.viewStudentListWithDetails));
        }
Example #15
0
        public IActionResult Index()
        {
            var studentIndexViewModel = new StudentIndexViewModel(_studentRepository.GetAll());

            return(View(studentIndexViewModel));
        }
Example #16
0
 public async Task OnGetAsync(StudentIndexViewModel studentModel)
 {
     StudentModel = await _studentViewModelService.GetStudents(0, Constants.ITEMS_PER_PAGE, studentModel.SearchFilter, studentModel.DepartmentFilterApplied);
 }
Example #17
0
        public async Task <IActionResult> StudentIndex()
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            var student = _context.Students
                          .Where(s => s.UserID == userId)
                          .AsNoTracking()
                          .SingleOrDefault();

            var model = new StudentIndexViewModel();


            var courseEnrollment = await _context.Enrollments
                                   .Where(e => e.StudentID == student.ID)
                                   .Include(e => e.Course)
                                   .ThenInclude(c => c.Department)
                                   .Include(e => e.Course)
                                   .ThenInclude(c => c.Questions)
                                   .AsNoTracking()
                                   .ToListAsync();

            model.Enrollments = courseEnrollment;

            try
            {
                var tweetUserId = _context.TwitterUsers
                                  .SingleOrDefault(u => u.UserID == userId)
                                  .ID;

                var following = _context.Follows
                                .Where(t => t.FollowerId == tweetUserId)
                                .Select(t => t.FolloweeId);

                model.Tweets = _context.Tweet
                               .OrderByDescending(x => x.DateTime)
                               .Where(u => following.Contains(u.TweetUserID))
                               .Take(10);

                foreach (var tweet in model.Tweets)
                {
                    var user = _userManager.FindByIdAsync(tweet.UserId).Result;

                    tweet.UserImage = "https://graph.facebook.com/" + user.FbProfile + "/?fields=picture&type=large";
                    tweet.UserName  = user.UserName;
                }
            }
            catch (Exception e)
            {
            }



            try
            {
                return(View(model));
            }
            catch (Exception e)
            {
                return(View());
            }
        }