Ejemplo n.º 1
0
        public void AddStudent()
        {
            var connection = DbConnectionFactory.CreateTransient();
            var context    = new StudentHostelContext(connection);
            StudentListViewModel viewModel = new StudentListViewModel(context);

            int count = viewModel.StudentList.Count;

            viewModel.AddCommand.Execute("");
            viewModel.CurrentStudent = new StudentViewModel
            {
                StudentId   = 0,
                Name        = "Test Student",
                Phone       = "123-123",
                Description = "Test",
                GroupName   = "2П"
            };
            viewModel.SaveCommand.Execute("");

            // Получаем новую запись из контекста
            var student = context.Students.Where(p => p.StudentId == count + 1).FirstOrDefault();

            // Проверяем, что количество записей увеличилось на 1
            Assert.AreEqual(count + 1, viewModel.StudentList.Count);
            Assert.AreEqual(count + 1, context.Students.Count());
            // Проверяем, что поле Имя сохранено верно
            Assert.AreEqual("Test Student", student.Name);
            Assert.AreEqual("Test Student", viewModel.StudentList[count].Name);
            // Проверяем, что поле Группа сохранено верно
            Assert.AreEqual("2П", student.Group.GroupName);
            Assert.AreEqual("2П", viewModel.StudentList[count].GroupName);
        }
Ejemplo n.º 2
0
    public ActionResult List(StudentListViewModel viewModel)
    {
        var students = _data.GetStudents(viewModel.Page, viewModel.PageSize, viewModel.Sort, viewModel.SortDirection);

        viewModel.Students = students.ToList();
        return(View(viewModel));
    }
        public ActionResult Index(StudentListViewModel oStudentListViewModel)
        {
            oStudentListViewModel.Sex       = oStudentListViewModel.GetSex();
            oStudentListViewModel.Countries = oStudentListViewModel.GetCountries();

            return(View(oStudentListViewModel));
        }
Ejemplo n.º 4
0
        public PartialViewResult GetListofStudent()
        {
            var studentListViewModel = new StudentListViewModel();
            var studentList          = studentListViewModel.CopyModelToViewModel(_studentService.GetAllStudent());

            return(PartialView("_StudentList", studentList));
        }
Ejemplo n.º 5
0
        public IActionResult Toggle(StudentListViewModel model)
        {
            if (model.Education.EducationId != 0)
            {
                Education education = educationRepo.Educations.FirstOrDefault(e => e.EducationId == model.Education.EducationId);
                model.Education = education;

                model.StudentsList   = studentRepo.GetAllStudentsFromEducation(education);
                model.IndicationList =
                    new CalculateAbsence().IndicationForStudents(model.StudentsList, absenceRepo.AbsenceByEducation(education));
                model.Course = null;
            }
            else if (model.Course.CourseId != 0)
            {
                Course course = ApplyCourseWithId(model.Course.CourseId);
                model.Course = course;

                model.StudentsList   = studentRepo.GetAllStudentsFromCourses(course);
                model.IndicationList = new CalculateAbsence().IndicationForStudents(model.StudentsList, absenceRepo.AbsenceByCourse(course));
            }

            if (model.IsChecked != "off")
            {
                model.IsChecked = "off";
                ViewBag.Check   = false;
                return(View("AbsenceList", model));
            }
            else
            {
                model.IsChecked = "on";
                ViewBag.Check   = true;
                return(View("AbsenceList", model));
            }
        }
Ejemplo n.º 6
0
        public ActionResult List()
        {
            var studentsInDb = _studentService.GetStudents();

            var studentDtos = new List <StudentDto>();

            foreach (var student in studentsInDb)
            {
                var studentDto = Mapper.Map <Student, StudentDto>(student);
                studentDto.CityDto = Mapper.Map <City, CityDto>(student.City);

                switch (student.Gender)
                {
                case false:
                    studentDto.Gender = Gender.Kadın;
                    break;

                case true:
                    studentDto.Gender = Gender.Erkek;
                    break;
                }

                studentDto.GraduateInfo = studentDto.EndingDate.HasValue ? "Mezun" : "Devam ediyor.";

                studentDtos.Add(studentDto);
            }

            var viewModel = new StudentListViewModel
            {
                StudentDtos = studentDtos
            };

            return(View(viewModel));
        }
Ejemplo n.º 7
0
        public ActionResult Index(int AccessLevel)
        {
            ViewBag.AccessLevel = AccessLevel;
            var studentList = new StudentListViewModel();

#pragma warning disable IDE0017 // Simplify object initialization
            var student = new StudentViewModel();
#pragma warning restore IDE0017 // Simplify object initialization
            student.FirstName = "John";
            student.LastName  = "Cena";
            student.Grade     = "B";

#pragma warning disable IDE0017 // Simplify object initialization
            var student1 = new StudentViewModel();
#pragma warning restore IDE0017 // Simplify object initialization
            student1.FirstName = "Betty";
            student1.LastName  = "Crocker";
            student1.Grade     = "C";

#pragma warning disable IDE0017 // Simplify object initialization
            var student2 = new StudentViewModel();
#pragma warning restore IDE0017 // Simplify object initialization
            student2.FirstName = "Jose";
            student2.LastName  = "Cuervo";
            student2.Grade     = "A";

            studentList.Students.Add(student);
            studentList.Students.Add(student2);
            studentList.Students.Add(student1);

            studentList.AccessLevel = AccessLevel;
            return(View(studentList));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> List(StudentFilterViewModel studentFilterViewModel)
        {
            var studentListViewModel = new StudentListViewModel();

            var studentListResult = await _studentManager.GetList(_mapper.Map <StudentFilterModel>(studentFilterViewModel));

            if (studentListResult.IsOk)
            {
                var students = _mapper.Map <List <StudentMvcDto> >(studentListResult.Data.Students);
                studentListViewModel.Students = students;
            }

            var timeTextResult = await _studentManager.GetCachedData();

            studentListViewModel.TimeText      = timeTextResult.Data;
            studentListViewModel.ReturnMessage = Resource.OperationCompletedSuccessfully;


            studentFilterViewModel.Genders = await _optionManager.GetGenders();

            var result = (StudentListViewModel : studentListViewModel,
                          StudentFilterViewModel : studentFilterViewModel);


            return(View(result));
        }
        public ActionResult Index()
        {
            StudentListViewModel osvm = new StudentListViewModel();

            osvm.Sex       = osvm.GetSex();
            osvm.Countries = osvm.GetCountries();
            return(View(osvm));
        }
Ejemplo n.º 10
0
        //
        // GET: /Student/
        public ActionResult Index()
        {
            var studentListViewModel = new StudentListViewModel();

            studentListViewModel.FormTitle   = "Student List";
            studentListViewModel.StudentList = studentListViewModel.CopyModelToViewModel(_studentService.GetAllStudent());
            return(View(studentListViewModel));
        }
Ejemplo n.º 11
0
        public ActionResult Sinfo()
        {
            JXGLBusinessLayer    students = new JXGLBusinessLayer();
            StudentListViewModel models   = new StudentListViewModel();

            models.Students = students.GetStudents(HttpContext.Session["UserName"].ToString());
            return(View("TSView", models));
        }
Ejemplo n.º 12
0
        public IActionResult UserPage()
        {
            ViewBag.Title = "User";
            StudentListViewModel listV = new StudentListViewModel {
                Students = repository.Students
            };

            return(View(listV));
        }
Ejemplo n.º 13
0
        public ActionResult List()
        {
            var studentList   = new StudentListViewModel();
            var studentsListb = _userService.GetAllStudents();
            var bannedList    = _userService.GetAllBanned();

            studentList.Students = studentsListb.Select(x => x.Map()).ToList();
            studentList.Banned   = bannedList.Select(x => x.Map()).ToList();
            return(View(studentList));
        }
Ejemplo n.º 14
0
        public StudentListViewModel MapToStudentListViewModel(GroupSet group, List <StudentSet> students)
        {
            var studentListViewModel = new StudentListViewModel()
            {
                Group    = group,
                Students = students
            };

            return(studentListViewModel);
        }
Ejemplo n.º 15
0
        public ActionResult Index(StudentListViewModel viewModel)
        {
            viewModel.StudentList =
                this._studentManager
                    .GetByInstitute(this.HttpContext.Cache.GetInstitutionID())
                    .Select(StudentMapper.ToViewModelExpression.Compile())
                    .ToList();

            return View(viewModel);
        }
        public ActionResult Index()
        {
            List <Student> students = repository.GetAll();

            StudentListViewModel model = new StudentListViewModel();

            model.Students = students;

            return(View(model));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,FirstName,LastName,Email,CourseId")] StudentListViewModel student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            var courseId = student.CourseId;

            if (ModelState.IsValid)
            {
                var user = await userManager.FindByIdAsync(id);

                try
                {
                    //_context.Update(student);
                    //var setEmailResult = await userManager.SetEmailAsync(user, student.Email);
                    user.FirstName = student.FirstName;
                    user.LastName  = student.LastName;
                    user.Email     = student.Email;

                    // Replace composite key
                    // TODO: Should remove all courses not only the first
                    List <LMSUserCourse> previousCourses = _context.LMSUserCourses
                                                           .Where(u => u.LMSUserId == user.Id).ToList();
                    _context.RemoveRange(previousCourses);

                    var newCourse = new LMSUserCourse
                    {
                        CourseId  = student.CourseId,
                        LMSUserId = student.Id
                    };
                    _context.Add(newCourse);
                    //user.RegisteredCourses = student.RegisteredCourses;
                    //user.RegisteredCourses = new LMSUserCourse
                    //{

                    //}
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Participant)));
            }
            return(View(student));
        }
        public IActionResult EnrrollStudent(int courseId)
        {
            ViewBag.Title = "User";
            Course course = repository.GetById(courseId);
            StudentListViewModel listV = new StudentListViewModel {
                Courses  = course,
                Students = repository.Students
            };

            return(View("List", listV));
        }
Ejemplo n.º 19
0
        public void GetAllStudents()
        {
            var connection = DbConnectionFactory.CreateTransient();
            var context    = new StudentHostelContext(connection);
            StudentListViewModel viewModel = new StudentListViewModel(context);

            var groupsInVM      = viewModel.StudentList;
            var groupsInContext = context.Students.Where(p => !p.SoftDeleted);

            // Проверяем, что количествозаписей во VM = количеству неудаленных записей в контексте
            Assert.AreEqual(groupsInContext.Count(), groupsInVM.Count);
        }
Ejemplo n.º 20
0
        // GET: Student
        public async Task <IActionResult> Index(int?id)
        {
            var student = await _context.Student.Where(m => m.Id == id).Include(m => m.Courses).FirstOrDefaultAsync();

            var enrollments   = _context.Enrollment.Where(m => m.StudentId == id).Include(m => m.Course).Include(m => m.Student);
            var studentlistVM = new StudentListViewModel
            {
                Student     = student,
                Enrollments = enrollments.ToList()
            };

            return(View(studentlistVM));
        }
        public IActionResult CreateStudents(Student student)
        {
            ViewBag.Title = "User";
            if (ModelState.IsValid)
            {
                repository.SaveStudent(student);
            }
            StudentListViewModel listV = new StudentListViewModel {
                Students = repository.Students
            };

            return(View("List", listV));
        }
Ejemplo n.º 22
0
        public void SetUp()
        {
            StudentRepoMoq    = new Mock <IStudentRepository>();
            ClassRepoMoq      = new Mock <IClassRepository>();
            RefreshServiceMoq = new Mock <IRefreshService>();
            var LoggerMoq = new Mock <ILogger <StudentListViewModel> >();

            viewModel = new StudentListViewModel(StudentRepoMoq.Object,
                                                 ClassRepoMoq.Object,
                                                 RefreshServiceMoq.Object,
                                                 LoggerMoq.Object);


            math = new Course()
            {
                CourseId = 1, CourseName = "math"
            };
            science = new Course()
            {
                CourseId = 2, CourseName = "science"
            };
            adam = new Student()
            {
                StudentName = "adam", StudentId = 1
            };
            benny = new Student()
            {
                StudentName = "benny", StudentId = 2
            };
            spencer = new Student()
            {
                StudentName = "spencer", StudentId = 3
            };

            mondayAfternoon = new ClassModel()
            {
                ClassId   = 1,
                ClassName = "monday afternoon's class"
            };

            var studentList = new List <Student>()
            {
                adam, benny, spencer
            };
            var classList = new ClassModel[] { mondayAfternoon };

            ClassRepoMoq.Setup(cr => cr.GetAllClassesAsync()).ReturnsAsync(classList);
            StudentRepoMoq.Setup(sr => sr.GetListAsync()).ReturnsAsync(studentList);
            StudentRepoMoq.Setup(sr => sr.GetStudentsByClassAsync(mondayAfternoon.ClassId))
            .ReturnsAsync(new Student[] { adam, spencer });
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> OnGetAsync(int studentPage = 1, string searchLastName = null, string searchYear = null, string searchHouse = null)
        {
            StudentListViewModel = new StudentListViewModel()
            {
                StudentList = await _db.Students.ToListAsync()
            };

            StringBuilder param = new StringBuilder();

            param.Append("/Students?studentPage=:");

            if (searchLastName != null)
            {
                param.Append("&searchLastName=");
                param.Append(searchLastName);
                StudentListViewModel.StudentList = StudentListViewModel.StudentList.Where(s => s.LastName == searchLastName).ToList();
            }

            if (searchYear != null)
            {
                param.Append("&searchYear=");
                param.Append(searchYear);
                StudentListViewModel.StudentList = StudentListViewModel.StudentList.Where(s => s.Year == Convert.ToInt32(searchYear)).ToList();
            }

            if (searchHouse != null)
            {
                param.Append("&searchHouse=");
                param.Append(searchHouse);
                StudentListViewModel.StudentList = StudentListViewModel.StudentList.Where(s => s.House == searchHouse).ToList();
            }

            var count = StudentListViewModel.StudentList.Count;

            StudentListViewModel.PagingInfo = new PagingInfo()
            {
                CurrentPage   = studentPage,
                ItemsPerPage  = SD.PaginationUserPageSize,
                TotalItems    = count,
                UrlParameters = param.ToString()
            };

            StudentListViewModel.StudentList = StudentListViewModel.StudentList
                                               .OrderBy(u => u.LastName)
                                               .Skip((studentPage - 1) * SD.PaginationUserPageSize)
                                               .Take(StudentListViewModel.PagingInfo.ItemsPerPage).ToList();

            return(Page());
        }
        public StudentListPage(StudentClass studentClass)
        {
            InitializeComponent();
            _viewModel     = new StudentListViewModel(studentClass);
            BindingContext = _viewModel;

            ToolbarItems.Add(new ToolbarItem("", "Add", async() =>
            {
                await Navigation.PushAsync(new AddNewStudentPage(studentClass));
            }));
            ToolbarItems.Add(new ToolbarItem("", "SendToAll", async() =>
            {
                await Navigation.PushPopupAsync(new AddMessagePopup());
            }));
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> List()
        {
            var studentListViewModel = new StudentListViewModel {
                Students = new List <StudentMvcDto>()
            };

            var genders = await _optionManager.GetGenders();

            var studentFilterViewModel = new StudentFilterViewModel {
                Genders = genders
            };

            var result = (StudentListViewModel : studentListViewModel,
                          StudentFilterViewModel : studentFilterViewModel);

            return(View(result));
        }
Ejemplo n.º 26
0
        /// GET: Available student list
        ///
        //[Authorize]
        public ActionResult Index()
        {
            StudentListViewModel stuListVM = new StudentListViewModel();

            List <Student> students = stuBL.GetStudents();

            List <StudentViewModel> stuVMs = new List <StudentViewModel>();

            foreach (Student stu in students)
            {
                StudentViewModel stuVM = new StudentViewModel(stu);
                stuVMs.Add(stuVM);
            }

            stuListVM.Students = stuVMs;
            return(View("Index", stuListVM));
        }
        public PartialViewResult GetStudentData(int page = 1)
        {
            int total = 0;
            IEnumerable <td_students> result = StudentService.GetPageEntites <string>(PageSize, page, out total, u => true, t => t.school_code, true);
            StudentListViewModel      model  = new StudentListViewModel
            {
                Students   = result,
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = 1,
                    ItemsPerPage = PageSize,
                    TotalItems   = total
                }
            };

            return(PartialView(model));
        }
Ejemplo n.º 28
0
        public StudentListView()
        {
            InitializeComponent();
            var studentListViewModel = new StudentListViewModel();
            var task = Task.Run(async() =>
            {
                studentListViewModel.ICollectionViewStudents = new QueryableCollectionView(new ObservableCollection <Students>((List <Students>) await StudentsRepository.GetInstance().GetStudentsAsync()));
            });

            task.GetAwaiter().OnCompleted(() =>
            {
                studentsGridView.ItemsSource     = studentListViewModel.ICollectionViewStudents;
                studentsGridDataForm.ItemsSource = studentListViewModel.ICollectionViewStudents;
                studentsGridView.IsBusy          = false;
                studentsGridDataForm.IsEnabled   = true;
            });
        }
Ejemplo n.º 29
0
        public ActionResult StudentSearch(StudentListViewModel studentListVm)
        {
            var lowerString = studentListVm.SearchString?.ToLower(); // check if searchString is null. if not then save it in lowerString

            if (!string.IsNullOrWhiteSpace(studentListVm.SearchString))
            {
                // will check searchString against first name, last name, studentId and ticket number and return any records that match

                studentListVm.Students = studentListVm.Students
                                         .Where(s => s.StudentFirstName.ToLower().Contains(lowerString) ||
                                                s.StudentLastName.ToLower().Contains(lowerString) ||
                                                s.TicketNumber.ToLower().Contains(lowerString) ||
                                                s.StudentId.ToString().ToLower().Contains(lowerString))
                                         .ToList();
            }

            return(View("StudentList", studentListVm));
        }
Ejemplo n.º 30
0
        [Authorize(Policy = "GivFraværPolicy")] //mangler implementation i visning
        public ViewResult AbsenceList(long courseId, long educationId, string dateString, bool edit)
        {
            StudentListViewModel model = new StudentListViewModel();

            string[] dateSplit = dateString.Split("-", 3);
            DateTime date      = new DateTime(int.Parse(dateSplit[2].Split(" ", 2)[0]), Int32.Parse(dateSplit[1]), int.Parse(dateSplit[0]));

            if (educationId != 0)
            {
                Education      education = educationRepo.Educations.FirstOrDefault(e => e.EducationId == educationId);
                List <Student> students  = studentRepo.GetAllStudentsFromEducation(education);

                model = new StudentListViewModel {
                    Date           = date,
                    AbsencesList   = AbsenceForStudentListByEducation(education, date),
                    Edit           = edit,
                    IndicationList = new CalculateAbsence().IndicationForStudents(students, absenceRepo.AbsenceByEducation(education)),
                    IsChecked      = "on",
                    StatusList     = new string[students.Count],
                    StudentsList   = students,
                    Education      = education
                };
            }
            else if (courseId != 0)
            {
                Course         course   = ApplyCourseWithId(courseId);
                List <Student> students = studentRepo.GetAllStudentsFromCourses(course);

                model = new StudentListViewModel {
                    Date           = date,
                    AbsencesList   = AbsenceForStudentList(courseId, date),
                    Edit           = edit,
                    IndicationList = new CalculateAbsence().IndicationForStudents(students, absenceRepo.AbsenceByCourse(course)),
                    IsChecked      = "on",
                    StatusList     = new string[students.Count],
                    StudentsList   = students,
                    Course         = course,
                };
            }

            ViewBag.Check = true;

            return(View("AbsenceList", model));
        }
        public async Task <IActionResult> Index()
        {
            // Get data from the data store
            var students = await _studentService.ReadAllAsync();

            // Create the ViewModel, based on the data
            var viewModel = new StudentListViewModel
            {
                Students = students.Select(student => new StudentListItemViewModel
                {
                    Id         = student.Id,
                    Name       = student.Name,
                    ClassCount = student.Classes.Count()
                })
            };

            // Return the View
            return(View(viewModel));
        }