Пример #1
0
        public StudentViewModel Get(Expression <Func <Student, bool> > predicate)
        {
            var student = _studentRepository.Get(predicate, student => student.Courses);
            var vm      = new StudentViewModel()
            {
                Id            = student.Id,
                Name          = student.Name,
                Email         = student.Email,
                Telephone     = student.Telephone,
                Country       = student.Country,
                DateOfBirth   = student.DateOfBirth,
                Gender        = student.Gender,
                Biography     = student.Biography,
                InstituteName = student.InstituteName,
                DegreeTitle   = student.DegreeTitle,
                PassingYear   = student.PassingYear,
                Result        = student.Result
            };

            vm.SetService(this as IStudentService);
            //foreach (var cs in course.Students)
            //{
            //    var s = _studentService.Get(cs.StudentId);
            //    vm.Students.Add(new StudentViewModel(_studentService)
            //    {
            //        Id = s.Id,
            //        Name = s.Name,
            //        Mark = s.Mark,
            //    });
            //}
            return(vm);
        }
Пример #2
0
        public IActionResult Index()
        {
            var vm = new StudentViewModel();

            vm.SetService(_service);
            vm.Read();
            return(View(vm));
        }
Пример #3
0
 public IActionResult Edit(string id, StudentViewModel vm)
 {
     if (!ModelState.IsValid)
     {
         return(View(vm));
     }
     vm.SetService(_studentService);
     vm.Update(Guid.Parse(id), vm);
     return(RedirectToAction("Index"));
 }
Пример #4
0
        public IActionResult Add(StudentViewModel vm)
        {
            vm.SetService(_studentService);

            vm.Create();
            if (_studentService.Get(s => s.Name == vm.Name) != null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(vm));
        }
Пример #5
0
        public StudentViewModel Get(Student student)
        {
            var s = _studentRepository.Get(student);

            var vm = new StudentViewModel()
            {
                Id            = s.Id,
                Name          = s.Name,
                Email         = s.Email,
                Telephone     = s.Telephone,
                Country       = s.Country,
                DateOfBirth   = s.DateOfBirth,
                Gender        = s.Gender,
                Biography     = s.Biography,
                InstituteName = s.InstituteName,
                DegreeTitle   = s.DegreeTitle,
                PassingYear   = s.PassingYear,
                Result        = s.Result
            };

            vm.SetService(this as IStudentService);
            return(vm);
        }