public JsonResult InsertNewBook(InsertBookDto dto) { if (ModelState.IsValid) { Services.KutuphaneService.InsertNewBook(dto); return(Json(Services.KutuphaneService.Result)); } return(Json(false)); }
public async Task InsertBook(InsertBookDto model) { if (model == null) { throw new ApiException(statusCode: System.Net.HttpStatusCode.BadRequest); } var bookModel = mapper.Map <Book>(model); await _books.AddAsync(bookModel); }
public void InsertNewBook(InsertBookDto dto) { var newBook = new Book { Author = dto.Author, Title = dto.Title, Isbn = dto.Isbn, Status = GeneralConsts.KitapDurumuKutuphanede }; UnitOfWork.CurrentSession.Books.Save(newBook); SetResultAsSuccess(ServiceResultCode.Success, "Yeni Kitap Eklendi"); }
public void UpdateBook(InsertBookDto dto) { var book = UnitOfWork.CurrentSession.Books.AsQueryable() .FirstOrDefault(p => p.Isbn == dto.Isbn); if (book != null) { book.Author = dto.Author; book.Title = dto.Title; UnitOfWork.CurrentSession.Books.Save(book); SetResultAsSuccess(ServiceResultCode.Success, "Kitap Güncellendi"); return; } SetResultAsFail(ServiceResultCode.Fail, "Kitap Güncellenemedi"); }
public async Task <ActionResult> InsertBook(InsertBookDto createBook) { await mediator.Send(new CreateBookCommand(createBook)); return(Ok()); }
public JsonResult UpdateBook(InsertBookDto dto) { Services.KutuphaneService.UpdateBook(dto); return(Json(Services.KutuphaneService.Result)); }