public IActionResult Update(BookDto book) { if (ModelState.IsValid) { _booksService.Update(book.ToDomainModel()); return(Ok()); } else { return(BadRequest(ModelState)); } }
public IActionResult Create(BookDto book) { if (ModelState.IsValid) { var status = _booksService.Create(book.ToDomainModel()); if (status) { return(Ok()); } else { ModelState.AddModelError("", "Book with same title already exists"); } } return(BadRequest(ModelState)); }
public async Task <IActionResult> Create(BookDto book) { var user = User; if (ModelState.IsValid) { var status = await _booksService.CreateAsync(book.ToDomainModel()); if (status) { return(Ok()); } else { ModelState.AddModelError("", "Book with same title already exists"); } } return(BadRequest(ModelState)); }