public Result <Book> Cancel(Guid bookId, bool isAdmin = false) { var book = _repository.Get().Include(x => x.BookUsers).FirstOrDefault(x => x.Id == bookId); if (book == null) { throw new ShareBookException(ShareBookException.Error.NotFound); } if (!isAdmin && book.BookUsers != null && book.BookUsers.Count > 0) { throw new ShareBookException("Este livro já possui interessados"); } book.Approved = false; book.ChooseDate = null; book.Canceled = true; _repository.Update(book); _booksEmailService.SendEmailBookCanceledToAdmins(book).Wait(); return(new Result <Book>(book)); }