public async Task ShouldCreate()
        {
            var command = new CreateCursoCommand
            {
                Nombre         = "curso 55",
                Descripcion    = "Become an expert in .NET Core with the latest technologies",
                TipoAsistencia = "Asíncrono",
                Precio         = 84.99M,
                Calificacion   = 4.95M,
                UrlImagen      = "https://i.imgur.com/LtR5agQ.jpeg",
                DocenteId      = 1,
                CategoriaId    = 2
            };

            var result = await SendAsync(command);

            var item = await FindAsync <Curso>(result);

            item.Should().NotBeNull();

            item.Nombre.Should().Be(command.Nombre);
            item.Descripcion.Should().Be(command.Descripcion);
            item.TipoAsistencia.Should().Be(command.TipoAsistencia);
            item.Precio.Should().Be(command.Precio);
            item.Calificacion.Should().Be(command.Calificacion);
            item.UrlImagen.Should().Be(command.UrlImagen);
            item.DocenteId.Should().Be(command.DocenteId);
        }
Пример #2
0
 public CommandResult Create(
     [FromBody] CreateCursoCommand command,
     [FromServices] CursoHandler handler
     )
 {
     return((CommandResult)handler.Handle(command));
 }
Пример #3
0
        public async Task <ActionResult <CreateCursoCommand> > Create(CreateCursoCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(command));
            }

            await _cursoService.Create(_mapper.Map <Curso>(command));

            return(CustomResponse(command));
        }
Пример #4
0
 public async Task <ActionResult <BaseApiResponse <int> > > Create(CreateCursoCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }