Exemplo n.º 1
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            var dto = ObjectMapper.Map <CreateEditBookViewModel, CreateUpdateBookDto>(ViewModel);
            await _service.UpdateAsync(Id, dto);

            return(NoContent());
        }
        public async Task UpdateAsync()
        {
            // Arrange
            var input = new BookUpdateDto()
            {
                Name = "0a0141e1329e48adbd91f1d21a567a142517734d1cc3420b9464df6a3e5d84020d6a1171f2654a7a91c29de099ca4d312fce"
            };

            // Act
            var serviceResult = await _bookAppService.UpdateAsync(Guid.Parse("682c0b6a-1d72-4094-b180-cea1dab40ed5"), input);

            // Assert
            var result = await _bookRepository.FindAsync(c => c.Id == serviceResult.Id);

            result.ShouldNotBe(null);
            result.Name.ShouldBe("0a0141e1329e48adbd91f1d21a567a142517734d1cc3420b9464df6a3e5d84020d6a1171f2654a7a91c29de099ca4d312fce");
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Put([FromBody] BookViewModel bookViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                var bookViewModelResult = await _bookAppService.UpdateAsync(bookViewModel);

                if (bookViewModelResult?.Data == null)
                {
                    return(BadRequest(new { message = "A problem occurred during updating the data." }));
                }

                return(Ok(bookViewModelResult.Data));
            }
            catch (ExceptionHandler exceptionHandler)
            {
                return(ResponseByHttpStatusCode(exceptionHandler));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            await _bookAppService.UpdateAsync(Id, Book);

            return(NoContent());
        }
Exemplo n.º 5
0
 public async Task <BookDto> UpdateAsync(Guid id, CreateUpdateBookDto input)
 {
     return(await _bookAppService.UpdateAsync(id, input));
 }
Exemplo n.º 6
0
 public virtual Task <BookDto> UpdateAsync(Guid id, BookUpdateDto input)
 {
     return(_bookAppService.UpdateAsync(id, input));
 }
Exemplo n.º 7
0
 public Task <BookDto> UpdateAsync(Guid id, CreateUpdateBookDto input)
 {
     return(_service.UpdateAsync(id, input));
 }