public ActionResult Create(CreateStudentViewModel viewModel)
        {
            var request = new StudentCreate.Request(SystemPrincipal.Name, viewModel.CommandModel);
            var response = DomainServices.Dispatch(request);

            if (!response.HasValidationIssues)
                return RedirectToAction("Index");

            ModelState.AddRange(response.ValidationDetails);
            return View(viewModel);
        }
        public ActionResult Create(CreateStudentViewModel viewModel)
        {
            var request  = new StudentCreate.Request(SystemPrincipal.Name, viewModel.CommandModel);
            var response = DomainServices.Dispatch(request);

            if (!response.HasValidationIssues)
            {
                return(RedirectToAction("Index"));
            }

            ModelState.AddRange(response.ValidationDetails);
            return(View(viewModel));
        }
Пример #3
0
        // Create student
        public static StudentCreate.Response Handle(IRepository repository, StudentCreate.Request request)
        {
            var container = new EntityStateWrapperContainer();

            container.AddEntity(StudentFactory.Create(request.CommandModel));
            var validationDetails = repository.Save(container);

            var studentId = default(int?);

            if (!validationDetails.HasValidationIssues)
            {
                studentId = container.FindEntity <Student>().ID;
            }

            return(new StudentCreate.Response(validationDetails, studentId));
        }