コード例 #1
0
        public async Task <ActionResult <Student> > PostStudent(Student student)
        {
            var command = new AddStudentCommand(student);
            var result  = await _mediator.Send(command);

            return(CreatedAtAction("GetStudent", new { id = result.Id }, result));
        }
コード例 #2
0
        private void ToolStripMenuAddStudent_Click(object sender, EventArgs e)
        {
            AddStudentCommand aStd = new AddStudentCommand(data, GetGroupIndexForGroup());

            inv.ExecuteAction(aStd);
            CreateTree();
            CheckUndoRedo();
        }
コード例 #3
0
        public IActionResult AddStudent([FromBody] StudentDto student)
        {
            EnsureArg.IsNotNull(student);

            var command = new AddStudentCommand(student);

            CommandDispatcher.Execute(command);
            return(Created("/api/students", command));
        }
コード例 #4
0
        public void fails_to_add_a_duplicate_student()
        {
            _rep.Insert(new Student(64646, "Pauliteiro de Mirandela"));
            var cmd = new AddStudentCommand {
                Id = 64646, Name = "Pauliteiro de Mirandela"
            };
            var handler = new AddStudent(_rep);

            Assert.Throws <DuplicateAggregateException>(() => handler.Handle(cmd));
        }
コード例 #5
0
 public void AddStudent(string name, string middleName, string surname)
 {
     if (uiManager.GroupSelected)
     {
         Student  student = new Student(name, middleName, surname);
         ICommand command = new AddStudentCommand(university[uiManager.SelectedGroupIndex], student);
         commandsManager.Execute(command);
         uiManager.UpdateUI();
     }
 }
コード例 #6
0
        public async Task <IActionResult> AddStudent([FromBody] AddStudentCommand addStudentCommand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var course = await _courseService.AddStudentToCourseAsync(addStudentCommand.CourseId,
                                                                      addStudentCommand.StudentId);

            return(Ok(course));
        }
コード例 #7
0
        public void adds_a_student()
        {
            var cmd = new AddStudentCommand {
                Id = 64646, Name = "Pauliteiro de Mirandela"
            };
            var handler = new AddStudent(_rep);

            handler.Handle(cmd);

            var student = _rep.Query <Student>().FirstOrDefault(f => f.Id == cmd.Id);

            Assert.NotNull(student);
            Assert.AreEqual(cmd.Name, student.Name);
        }
コード例 #8
0
        public IActionResult Create(CreateStudentViewModel createStudentViewModel, [FromServices] AddStudentCommand addStudentCommand)
        {
            // If the supplied viewmodel isn't valid, send it back
            if (!ModelState.IsValid)
            {
                return(View(createStudentViewModel));
            }

            var student = _mapper.Map <Student>(createStudentViewModel);

            addStudentCommand.Student           = student;
            addStudentCommand.SelectedCoursesId = createStudentViewModel.SelectedCourseIds;
            addStudentCommand.Run();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #9
0
 public async Task <IActionResult> Post([FromBody] AddStudentCommand studentCommand)
 {
     return(Ok(mediator.Send(studentCommand)));
 }
コード例 #10
0
 public async Task <IActionResult> AddStudent(AddStudentCommand request)
 {
     return(Ok(await _mediator.Send(request)));
 }
コード例 #11
0
 public async Task <IActionResult> AddStudent(AddStudentCommand command)
 {
     return(Ok(await mediator.Send(command)));
 }