コード例 #1
0
ファイル: TeacherService.cs プロジェクト: T316/SchoolSystem
        public EditStudentInfoVm GetStudentInfoById(int id)
        {
            Student           student = this.Context.Students.FirstOrDefault(s => s.Id == id);
            EditStudentInfoVm vm      = Mapper.Instance.Map <Student, EditStudentInfoVm>(student);

            return(vm);
        }
コード例 #2
0
        public void EditStudentInfo_InvalidStudent_ShouldReturnDefaultView()
        {
            EditStudentInfoVm vm = new EditStudentInfoVm()
            {
                Id             = 1,
                Name           = "Gosho Goshev",
                PersonalNumber = "0011126582"
            };

            _controller.WithCallTo(c => c.EditStudentInfo(vm, 2)).ShouldRenderDefaultView();
        }
コード例 #3
0
ファイル: TeacherService.cs プロジェクト: T316/SchoolSystem
        public void EditStudentInfo(EditStudentInfoVm vm)
        {
            Student student = this.Context.Students.FirstOrDefault(s => s.Id == vm.Id);

            student.Name           = vm.Name;
            student.PersonalNumber = vm.PersonalNumber;
            student.Address        = vm.Address;
            student.PhoneNumber    = vm.PhoneNumber;
            student.ParentName     = vm.ParentName;
            student.ParentPhone    = vm.ParentPhone;

            this.Context.Entry(student).State = EntityState.Modified;
            this.Context.SaveChanges();
        }
コード例 #4
0
        public ActionResult EditStudentInfo(EditStudentInfoVm vm, int id)
        {
            if (!this.service.IsStudentExists(id))
            {
                this.ModelState.AddModelError("Student", "Ученикът трябва да фигурира в системата.");
            }

            if (this.ModelState.IsValid)
            {
                this.service.EditStudentInfo(vm);
                return(this.RedirectToAction("StudentDetails", "Students", new { id = vm.Id }));
            }

            return(this.View(vm));
        }
コード例 #5
0
        public ActionResult EditStudentInfo(int id)
        {
            EditStudentInfoVm vm = this.service.GetStudentInfoById(id);

            return(this.View(vm));
        }