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)); }
private void ToolStripMenuAddStudent_Click(object sender, EventArgs e) { AddStudentCommand aStd = new AddStudentCommand(data, GetGroupIndexForGroup()); inv.ExecuteAction(aStd); CreateTree(); CheckUndoRedo(); }
public IActionResult AddStudent([FromBody] StudentDto student) { EnsureArg.IsNotNull(student); var command = new AddStudentCommand(student); CommandDispatcher.Execute(command); return(Created("/api/students", command)); }
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)); }
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(); } }
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)); }
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); }
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))); }
public async Task <IActionResult> Post([FromBody] AddStudentCommand studentCommand) { return(Ok(mediator.Send(studentCommand))); }
public async Task <IActionResult> AddStudent(AddStudentCommand request) { return(Ok(await _mediator.Send(request))); }
public async Task <IActionResult> AddStudent(AddStudentCommand command) { return(Ok(await mediator.Send(command))); }