public LivroDTO Update(int id, LivroDTO LivroDTO)
        {
            var livro = _LivroService.Get(id);

            livro.UpdateData(LivroDTO.ISBN, LivroDTO.Autor, LivroDTO.Nome, LivroDTO.Preco, LivroDTO.Publicacao, LivroDTO.ImagemCapa);
            return(_LivroMapper.MapperToDTO(_LivroService.Update(livro)));
        }
        public void Deve_retornar_o_livro_pelo_id()
        {
            _livroRepository.BuscarPorId(Arg.Any <int>()).Returns(_listaLivros.First());

            var livroEsperado  = _listaLivrosView.First();
            var livroRetornado = _livroService.Get(livroEsperado.LivroId);

            Assert.AreEqual(livroEsperado.LivroId, livroRetornado.LivroId);
            Assert.AreEqual(livroEsperado.Titulo, livroRetornado.Titulo);
            Assert.AreEqual(livroEsperado.NomeDoAutor, livroRetornado.NomeDoAutor);
        }
Beispiel #3
0
        [Route("{id}", Name = "GetWithId")] //Seleconar um registro //chama intrenamente na controler
        public async Task <ActionResult> Get(Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState)); //400 bad request - solicitação inválida
            }

            try
            {
                return(Ok(await _livroService.Get(id)));                                 //200 - ok // get da service
            }
            catch (ArgumentException ex)                                                 // trata erro de controller
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); // erro 50
            }
        }
        public void LivroIntegracao_Adicionar_ShouldBeOk()
        {
            int   biggerThan       = 0;
            int   sizeListExpected = 2;
            Livro livro            = _service.Adicionar(ObjectMotherLivro.GetLivro());

            livro.Id.Should().BeGreaterThan(biggerThan);
            var last = _service.Get(livro.Id);

            last.Should().NotBeNull();
            var posts = _service.GetAll();

            posts.Count().Should().Be(sizeListExpected);
        }
Beispiel #5
0
        public ActionResult <LivroDto> Get(int id)
        {
            var result = _livroService.Get(id);

            return(Ok(result));
        }
 public LivroListViewModel Get()
 {
     return(_livroService.Get());
 }
 public void Quando_obter_um_livro_por_id_deve_mapear_corretamente()
 {
     LivroService.Get(LivroComId.Id).Should().BeEquivalentTo(LivroVmComId);
 }
 public IActionResult Get(int id)
 {
     return(Ok(_livroService.Get(id)));
 }
Beispiel #9
0
 public ActionResult <LivroViewModel> ObterLivroPeloId(int id)
 {
     return(_livroService.Get(id));
 }