Example #1
0
        public static List <BookReviewVM> GetBookReviewVMs(string baseUrl, QuerySearch query = null)
        {
            var returnBookReviews = QueryHelper.QueryList <BookReview>(query, "bookReview");
            var bookReviewVMs     = new List <BookReviewVM>();

            foreach (var br in returnBookReviews)
            {
                var vm = new BookReviewVM()
                {
                    Id           = br.Id,
                    ReviewerName = br.ReviewerName,
                    ReviewText   = br.ReviewText,
                    PublishDate  = br.PublishDate,
                    BookId       = br.BookId,
                    Rating       = br.Rating,
                };
                vm.SetDefaultLinks(baseUrl, "bookreview", br.ReviewerName);
                vm.Embed = new Embed(books: BookCollection.GetBookEmbed(baseUrl, new List <int>()
                {
                    br.BookId
                }));
                bookReviewVMs.Add(vm);
            }
            return(bookReviewVMs);
        }
Example #2
0
        public static List <AuthorVM> GetAuthorVMs(string baseUrl, QuerySearch query = null)
        {
            var returnAuthors = QueryHelper.QueryList <Author>(query, "author");
            var authorVMs     = new List <AuthorVM>();

            foreach (var aut in returnAuthors)
            {
                var vm = new AuthorVM()
                {
                    FirstName        = aut.FirstName,
                    LastName         = aut.LastName,
                    Id               = aut.Id,
                    HeadshotImageUrl = aut.HeadshotImageUrl
                };
                vm.SetDefaultLinks(baseUrl, "author", $"{aut.FirstName} {aut.LastName}");
                vm.Embed = new Embed(books: BookCollection.GetBookEmbed(baseUrl, aut.BookIds), categories: CategoryCollection.GetCategoryEmbed(baseUrl, aut.CategoryIds));
                authorVMs.Add(vm);
            }
            return(authorVMs);
        }
        public static List <CategoryVM> GetCategoryVMs(string baseUrl, QuerySearch query = null)
        {
            var returnCats  = QueryHelper.QueryList <Category>(query, "category");
            var categoryVMs = new List <CategoryVM>();

            foreach (var cat in returnCats)
            {
                var vm = new CategoryVM()
                {
                    Name = cat.Name,
                    Id   = cat.Id,
                };
                vm.SetDefaultLinks(baseUrl, "category", cat.Name);
                vm.Embed = new Embed(authors: AuthorCollection.GetAuthorEmbed(baseUrl, cat.AuthorIds), books: BookCollection.GetBookEmbed(baseUrl, cat.BookIds));
                categoryVMs.Add(vm);
            }
            return(categoryVMs);
        }