Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] BookCategoryDto bookCategoryDto)
        {
            await _bookCategoryService.SaveBookCategory(bookCategoryDto);

            var bookCategories = await _bookCategoryService.GetAllBookCategory();

            return(Ok(bookCategories));
        }
Ejemplo n.º 2
0
        public async Task <bool> SaveBookCategory(BookCategoryDto bookCategoryDto)
        {
            var bookCategory = Mapper.Map <BookCategoryDto, BookCategory>(bookCategoryDto);

            await _unitOfWork.BookCategories.Add(bookCategory);

            await _unitOfWork.SaveChanges();

            return(true);
        }
Ejemplo n.º 3
0
 public async Task <ActionResult <ApiResponse> > Put(int id, [FromBody] BookCategoryDto entity)
 {
     return(new ApiResponse($"The record with {id} was updated.",
                            await bookCategoryService.Update(id, mapper.Map <BookCategory>(entity))));
 }
Ejemplo n.º 4
0
 public async Task <ActionResult <ApiResponse> > Post([FromBody] BookCategoryDto entity)
 {
     return(new ApiResponse("New book category added.",
                            await bookCategoryService.Add(mapper.Map <BookCategory>(entity))));
 }