Exemple #1
0
        public ApiResponseDto <List <BookAuthorDto> > GetBook()
        {
            var book = _bookService.GetBook();
            List <BookAuthorDto> bookAuthorDtoList = new List <BookAuthorDto>();
            BookAuthorDto        bookAuthorDtos;

            if (book != null)
            {
                foreach (var item in book)
                {
                    var author = BAuthor.GetAuthorByID(item.FK_AuthorID);
                    bookAuthorDtos = new BookAuthorDto()
                    {
                        ID            = item.ID,
                        BookName      = item.Name,
                        PublishedYear = item.PublishedYear,
                        Cover         = item.Cover,
                        AuthorName    = author.Name
                    };
                    bookAuthorDtoList.Add(bookAuthorDtos);
                }
                return(ApiResponseDto <List <BookAuthorDto> > .SuccessResponse(bookAuthorDtoList, "basarili"));
            }

            return(ApiResponseDto <List <BookAuthorDto> > .FailedResponse("basarisiz"));
        }
Exemple #2
0
        public static void UpdateBook(BookAuthorDto book)
        {
            using (var uow = new UnitOfWork())
            {
                if (book == null || DBNull.Value.Equals(book))
                {
                    return;
                }
                else
                {
                    var BookInfo = uow.BookRepository.GetByID(book.ID);
                    var author   = uow.AuthorRepository.GetByID(BookInfo.FK_AuthorID);
                    if (book != null & book.ID == BookInfo.ID & BookInfo.FK_AuthorID == author.ID)
                    {
                        BookInfo.ID            = book.ID;
                        BookInfo.Name          = book.BookName;
                        BookInfo.PublishedYear = book.PublishedYear;
                        BookInfo.FK_AuthorID   = author.ID;
                    }

                    uow.BookRepository.Save(BookInfo);
                }
            }
        }
Exemple #3
0
 public void UpdateBook(BookAuthorDto book)
 {
     BBook.UpdateBook(book);
 }
        public int AddBookAuthor(BookAuthorDto authorDto)
        {
            var id = Execute("INSERT INTO [dbo].[BookAuthor]([BookId], [AuthorId]) OUTPUT INSERTED.AuthorId VALUES (@BookId, @AuthorId)", authorDto);

            return(id);
        }