Exemplo n.º 1
0
        public void Create_SchoolSubject_Created()
        {
            var schoolSubject = new SchoolSubject();

            _unitOfWorkMock.Setup(uof => uof.SchoolSubjectGenericRepository.Create(schoolSubject));

            _sut.Create(schoolSubject);

            _unitOfWorkMock.Verify(uof => uof.SchoolSubjectGenericRepository.Create(It.IsAny <SchoolSubject>()), Times.AtLeastOnce);
        }
        public ActionResult SchoolSubjectCreate(SchoolSubject schoolSubject)
        {
            if (!ModelState.IsValid | _schoolSubjectsService.Find(s => s.Name == schoolSubject.Name).Any())
            {
                ModelState.AddModelError("SchoolSubjectError", "This exam subject already exists.");

                return(View(schoolSubject));
            }

            _schoolSubjectsService.Create(schoolSubject);

            return(RedirectToAction("GetSchoolSubjects", "SchoolSubject", new { area = "Operator" }));
        }