public BookStoreMutation(IAuthorManager authorManager, IBookManager bookManager) { Field <AuthorType>( "addAuthor", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <AuthorInputType> > { Name = "author" }), resolve: context => { var author = context.GetArgument <Author>("author"); return(authorManager.Add(author)); }); Field <BookType>( "addBook", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <BookInputType> > { Name = "book" }), resolve: context => { var book = context.GetArgument <Book>("book"); return(bookManager.Add(book)); }); }
public IActionResult AddBook(BookDTO b) { if (ModelState.IsValid) { var book = mapper.Map <book>(b); bookManager.Add(book); return(StatusCode(201)); } return(BadRequest()); }
public async Task <ActionResult> Add([FromBody] Book book) { var isCreated = await _bookManager.Add(book); if (!isCreated) { return(StatusCode(500)); } return(StatusCode(201)); }
public IActionResult Create(Book book) { if (ModelState.IsValid) { book.CreatedAt = DateTime.Now; _iBookManager.Add(book); return(RedirectToAction(nameof(Index))); } ViewData["AuthorId"] = new SelectList(_iAuthorManager.GetAll(), "Id", "Name", book.AuthorId); ViewData["BookCategoryId"] = new SelectList(_iBookCategoryManager.GetAll(), "Id", "Name", book.BookCategoryId); ViewData["LanguageId"] = new SelectList(_iLanguageManager.GetAll(), "Id", "Name", book.LanguageId); ViewData["PublisherId"] = new SelectList(_iPublisherManager.GetAll(), "Id", "Name", book.PublisherId); return(View(book)); }