Exemple #1
0
 public AuthorServiceTests()
 {
     _authorService = new AuthorService(_authorRepositoryMock.Object);
 }
Exemple #2
0
 public void GetByBook_BadArgument_ReturnNull_Exception()
 {
     _mockAuthorRepository.Setup(w => w.GetAll()).ReturnsAsync(_authors);
     using var authorService = new AuthorService(_mockAuthorRepository.Object, _mapper);
     Assert.ThrowsAsync <CustomException>(() => authorService.GetByBook("123", It.IsAny <string>()));
 }
Exemple #3
0
 public void GetByLike_GoodArgument_ReturnTwoObject_Success()
 {
     _authors.Add(new Author
     {
         Id          = Guid.NewGuid().ToString(),
         FirstName   = "SomeAuthorFirstName",
         SecondName  = "SomeAuthorSecondName",
         ImageUrl    = "SomeImageUrl",
         AuthorBooks = new List <AuthorBook>
         {
             new AuthorBook
             {
                 Id       = Guid.NewGuid().ToString(),
                 AuthorId = Guid.NewGuid().ToString(),
                 BookId   = "123",
                 Book     = new Book(),
                 Author   = new Author()
             }
         },
         AuthorLikes = new List <AuthorLike>
         {
             new AuthorLike
             {
                 Id       = Guid.NewGuid().ToString(),
                 UserId   = "123",
                 User     = new User(),
                 Author   = new Author(),
                 AuthorId = Guid.NewGuid().ToString()
             }
         },
         AuthorComments = new List <AuthorComment>()
     });
     _authors.Add(new Author
     {
         Id          = Guid.NewGuid().ToString(),
         FirstName   = "SomeAuthorFirstName",
         SecondName  = "SomeAuthorSecondName",
         ImageUrl    = "SomeImageUrl",
         AuthorBooks = new List <AuthorBook>
         {
             new AuthorBook
             {
                 Id       = Guid.NewGuid().ToString(),
                 AuthorId = Guid.NewGuid().ToString(),
                 BookId   = "123",
                 Book     = new Book(),
                 Author   = new Author()
             }
         },
         AuthorLikes = new List <AuthorLike>
         {
             new AuthorLike
             {
                 Id       = Guid.NewGuid().ToString(),
                 UserId   = "123",
                 User     = new User(),
                 Author   = new Author(),
                 AuthorId = Guid.NewGuid().ToString()
             }
         },
         AuthorComments = new List <AuthorComment>()
     });
     _mockAuthorRepository.Setup(w => w.GetAll()).ReturnsAsync(_authors);
     using var authorService = new AuthorService(_mockAuthorRepository.Object, _mapper);
     Assert.AreEqual(authorService.GetByLike("123").Result.Count, 2);
 }
Exemple #4
0
 public AddBookForm(BookService bookService, AuthorService authorService)
 {
     BS = bookService;
     AS = authorService;
     InitializeComponent();
 }
Exemple #5
0
 public AuthorController()
 {
     _authorService = new AuthorService();
 }
Exemple #6
0
 public BookController(BookService bookService, CategoryService categoryService, PublisherService publisherService, AuthorService authorService)
 {
     _bookService      = bookService;
     _authorService    = authorService;
     _publisherService = publisherService;
     _categoryService  = categoryService;
 }
Exemple #7
0
        public frmBookDetail(Book book, User user)
        {
            InitializeComponent();
            var db = new BookStoreDB();
            // init services
            var authorService   = new AuthorService(db);
            var categoryService = new CategoryService(db);

            _bookService = new BookService(db);

            _book = book;
            // get list from service and bind to datasource
            cbxAuthor.DataSource    = authorService.List().OrderBy(t => t.Title).ToList();
            cbxAuthor.DisplayMember = "Title";
            cbxAuthor.ValueMember   = "Id";

            // create empty value
            var emptyCategory = new Category();

            emptyCategory.Id    = 0;
            emptyCategory.Title = String.Empty;

            // get list from service
            var categoryDataSource = categoryService.List().ToList();

            categoryDataSource.Add(emptyCategory);
            categoryDataSource = categoryDataSource.OrderBy(t => t.Title).ToList();

            // bind to datasource
            cbxCategory.DataSource    = categoryDataSource;
            cbxCategory.DisplayMember = "Title";
            cbxCategory.ValueMember   = "Id";

            if (book != null)
            {
                txtTitle.Text             = book.Title;
                rtbDescription.Text       = book.Description;
                txtPublisher.Text         = book.Publisher;
                txtYear.Text              = book.Year.ToString();
                cbxAuthor.SelectedValue   = book.AuthorId;
                cbxCategory.SelectedValue = book.CategoryId ?? 0;

                if (!string.IsNullOrEmpty(book.Cover))
                {
                    picCover.Image = Image.FromFile(Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + book.Cover);
                }

                btnSave.Text = "Update";
                if (user.Role.RoleType != BookStoreConstants.ADMIN_ROLE_TYPE)
                {
                    btnSave.Location  = btnDelete.Location;
                    btnDelete.Visible = false;
                }
            }

            else
            {
                btnSave.Text      = "Insert";
                btnSave.Location  = btnDelete.Location;
                btnDelete.Visible = false;
            }
        }
 public TechnicalRadiationController() // Constructor
 {
     _categoryService = new CategoryService();
     _newsItemService = new NewsItemService();
     _authorService   = new AuthorService();
 }
Exemple #9
0
 public BookController(BookService bookService, AuthorService authorService, IMapper mapper)
 {
     _bookService   = bookService;
     _authorService = authorService;
     _mapper        = mapper;
 }
Exemple #10
0
 public BookController(BookService bookService, IRepositoryWrapper repositoryWrapper, AuthorService authorService)
 {
     _bookService       = bookService;
     _repositoryWrapper = repositoryWrapper;
     _authorService     = authorService;
 }
Exemple #11
0
 private void AddUpdateItemCallbackFn(string item)
 {
     _authorService = new AuthorService(new BookStoreDB());
     SearchAuthor(txtFilter.Text);
 }
        public APIServiceQuery(BookService bookService, ProductService productService, AuthorService authorService)
        {
            Field <BookType>(
                "Book",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(bookService.GetBook(id));
            }
                );

            Field <ListGraphType <BookType> >(
                "Books",
                resolve: context => bookService.GetBooks()
                );


            Field <ListGraphType <AuthorType> >(
                "Authors",
                resolve: context => authorService.GetAuthors()
                );

            Field <AuthorType>(
                "Author",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(authorService.GetAuthor(id));
            }
                );

            Field <ProductType>(
                "Product",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(productService.GetProduct(id));
            }
                );

            Field <ListGraphType <ProductType> >(
                "Products",
                resolve: context => productService.GetProducts()
                );

            Field <BookCategoriesType>(
                "BookCategories",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(bookService.GetBookCategory(id));
            }
                );

            Field <CategoryType>(
                "Category",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(bookService.GetCategory(id));
            }
                );

            Field <ListGraphType <SizeType> >(
                "Sizes",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(productService.GetSizeOfProduct(id));
            }
                );
        }
Exemple #13
0
 public EditModel(AuthorService authorService)
 {
     _authorService = authorService;
 }
 public EmployeeController()
 {
     _bookService     = new BookService();
     _categoryService = new CategoryService();
     _authorService   = new AuthorService();
 }
 public AuthorsController()
 {
     authorService = new AuthorService();
     bookService   = new BookService();
 }
Exemple #16
0
 public BooksController(DatabaseContext context, BookService bookService, WriterService writerService, PublisherService publisherService, AuthorService authorService)
 {
     _context          = context;
     _bookService      = bookService;
     _writerService    = writerService;
     _publisherService = publisherService;
     _authorService    = authorService;
 }
 public AuthorController(AuthorService service)
 {
     _service = service;
 }
 public AuthorsController(AuthorService authorService)
 {
     _authorService = authorService;
 }
Exemple #19
0
 public AuthorController(AuthorService authorService, IWebHostEnvironment webHostEnvironment)
 {
     this.authorService      = authorService;
     this.webHostEnvironment = webHostEnvironment;
 }
Exemple #20
0
 //Widok do przeladowania tabeli
 public async Task <ActionResult> IndexPartial()
 => PartialView(await AuthorService.GetAll());
        public async Task RB(IDialogContext context, LuisResult result)
        {
            var entitiesArray = result.Entities;
            //    int k = 0;
            var resultMessage = context.MakeMessage();

            if (result.Query.StartsWith("Getting details of "))
            {
                string activity = result.Query;

                string titl = "", auth = "";
                int    lenby = activity.IndexOf("By "), lenend = activity.Length;
                titl = activity.Substring(22, lenby - 22);
                auth = activity.Substring((lenby + 3), (lenend - lenby - 3));
                var GRser1 = await BookService.GetBookInfo1(titl, auth);


                resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                resultMessage.Attachments      = new List <Attachment>();
                string        desc    = ((GRser1.items[0].volumeInfo.description.Length < 300) ? GRser1.items[0].volumeInfo.description : (GRser1.items[0].volumeInfo.description.Substring(0, 300) + "..."));
                ThumbnailCard plCard1 = new ThumbnailCard()
                {
                    Title    = GRser1.items[0].volumeInfo.title,
                    Subtitle = $"Author: \n{GRser1.items[0].volumeInfo.authors[0]} \n\nRating: \n{GRser1.items[0].volumeInfo.averageRating} \n\nDescription:  {desc}",
                    Images   = new List <CardImage>()
                    {
                        new CardImage()
                        {
                            Url = GRser1.items[0].volumeInfo.imageLinks.thumbnail,
                        }
                    },
                    Buttons = new List <CardAction>()
                    {
                        new CardAction()
                        {
                            Title = "Preview Link",
                            Type  = ActionTypes.OpenUrl,
                            Value = GRser1.items[0].volumeInfo.previewLink,
                        },
                        new CardAction()
                        {
                            Title = "Buy Book",
                            Type  = ActionTypes.OpenUrl,
                            Value = GRser1.items[0].saleInfo.buyLink,
                        }
                    }
                };
                Attachment plAttachment1 = plCard1.ToAttachment();
                resultMessage.Attachments.Add(plAttachment1);
                await context.PostAsync(resultMessage);
            }
            else
            {
                foreach (var entityItem in result.Entities)
                {
                    if (entityItem.Type == "bookTitle")
                    {
                        int i     = 0;
                        var GRser = await RecommendationService.GetRecommendationInfo(entityItem.Entity);

                        resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                        resultMessage.Attachments      = new List <Attachment>();

                        foreach (var item in GRser.book.similar_books)
                        {
                            HeroCard plCard = new HeroCard()
                            {
                                Title    = item.title,
                                Subtitle = item.authors.author.name,
                                Images   = new List <CardImage>()
                                {
                                    new CardImage()
                                    {
                                        Url = item.image_url
                                    },
                                },
                                Buttons = new List <CardAction>()
                                {
                                    new CardAction()
                                    {
                                        Title = "More details",
                                        Type  = ActionTypes.ImBack,
                                        Value = "Getting the details of " + item.title + " By " + item.authors.author.name
                                    }
                                }
                            };
                            Attachment plAttachment = plCard.ToAttachment();
                            resultMessage.Attachments.Add(plAttachment);
                            i++;
                        }

                        await context.PostAsync(resultMessage);
                    }

                    if (entityItem.Type == "author")
                    {
                        int i     = 0;
                        var GRser = await AuthorService.GetAuthorInfo(entityItem.Entity);

                        resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                        resultMessage.Attachments      = new List <Attachment>();

                        foreach (var item in GRser.search.results)
                        {
                            HeroCard plCard = new HeroCard()
                            {
                                Title    = item.best_book.title,
                                Subtitle = item.best_book.author.name,
                                Images   = new List <CardImage>()
                                {
                                    new CardImage()
                                    {
                                        Url = item.best_book.image_url
                                    },
                                },
                                Buttons = new List <CardAction>()
                                {
                                    new CardAction()
                                    {
                                        Title = "Get details",
                                        Type  = ActionTypes.ImBack,
                                        Value = "Getting the details of " + item.best_book.title + " By " + item.best_book.author.name
                                    }
                                }
                            };
                            Attachment plAttachment = plCard.ToAttachment();
                            resultMessage.Attachments.Add(plAttachment);
                            i++;
                        }

                        await context.PostAsync(resultMessage);
                    }

                    if (entityItem.Type == "genre")
                    {
                        int i     = 0;
                        var GRser = await GenreService.GetGenreInfo(entityItem.Entity);

                        resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                        resultMessage.Attachments      = new List <Attachment>();
                        var GRser1 = await BookService.GetBookInfo(entityItem.Entity);

                        foreach (var item in GRser.book)
                        {
                            HeroCard plCard = new HeroCard()
                            {
                                Title    = item.title,
                                Subtitle = item.author,
                                Buttons  = new List <CardAction>()
                                {
                                    new CardAction()
                                    {
                                        Title = "Get Details",
                                        Type  = ActionTypes.ImBack,
                                        Value = "Getting the details of " + item.title + " By " + item.author
                                    }
                                }
                            };
                            Attachment plAttachment = plCard.ToAttachment();
                            resultMessage.Attachments.Add(plAttachment);
                            i++;
                        }

                        await context.PostAsync(resultMessage);
                    }
                }
            }
            context.Wait(this.MessageReceived);
        }
Exemple #22
0
        public async Task <ActionResult> EditAuthorPost([Bind(Include = "Id,FirstName,LastName,LastNameForDisplay,Description")] Author author)
        {
            var result = await AuthorService.Edit(author);

            return(PartialView("_infoPartial", result));
        }
 public AuthorController(AuthorService service, IMapper mapper)
 {
     _service = service;
     _mapper  = mapper;
 }
Exemple #24
0
 public async Task <ActionResult> DeleteModal(int id)
 => PartialView(await AuthorService.GetById(id));
Exemple #25
0
 public AuthorController()
 {
     _bookService   = new BookService();
     _authorService = new AuthorService();
 }
Exemple #26
0
        public async Task <ActionResult> DeleteAuthorPost(int id)
        {
            var result = await AuthorService.Delete(id);

            return(PartialView("_infoPartial", result));
        }
Exemple #27
0
 public void GetByBook_NullArgument_Exception()
 {
     using var authorService = new AuthorService(_mockAuthorRepository.Object, _mapper);
     Assert.ThrowsAsync <CustomException>(() => authorService.GetByBook(null, It.IsAny <string>()));
 }
Exemple #28
0
        //Autorzy do selectListy
        public async Task <ActionResult> GetAuthorsForSelect(string searchString)
        {
            var model = await AuthorService.GetAuthorsForSelect(searchString);

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemple #29
0
 public void GetByLike_GoodArgument_ReturnNull_Exception()
 {
     _mockAuthorRepository.Setup(w => w.GetAll()).ReturnsAsync(() => null);
     using var authorService = new AuthorService(_mockAuthorRepository.Object, _mapper);
     Assert.ThrowsAsync <ServerException>(() => authorService.GetByLike("123"));
 }
Exemple #30
0
 public TesteController(LibraryContext ctx)
 {
     BookService   = new BookService(ctx);
     AuthorService = new AuthorService(ctx);
 }