示例#1
0
 // GET: api/Authors
 public AuthorListViewModel Get()
 {
     using (var provider = new AuthorProvider(connectionString))
     {
         return(AuthorListViewModel.FromModel(provider.GetAll()));
     }
 }
示例#2
0
        /* şuan burası pasif
         * public IActionResult BookRead(int id)
         * {
         *  Book book = _bookService.GetBookReadDetails(id);
         *
         *  return View(new BookDetailModel()
         *  {
         *      Book = book,
         *      Category = book.BookCategories.Select(i => i.Categories).ToList()
         *
         *  });
         * } */

        public IActionResult AuthorList()
        {
            AuthorListViewModel authorListViewModel = new AuthorListViewModel()//şurayı sor () olmadanda çalışıyor neden?
            {
                Authors = _authorServices.GetAll()
            };

            return(View(authorListViewModel));
        }
        public IActionResult AuthorList()
        {
            AuthorListViewModel authorListViewModel = new AuthorListViewModel()
            {
                Authors = _authorServices.GetAll()
            };

            return(View(authorListViewModel));
        }
        public IActionResult AuthorSearch(string q)
        {
            var authorListViewModel = new AuthorListViewModel()
            {
                Authors = _authorServices.GetSearchResult(q)
            };

            return(View(authorListViewModel));
        }
示例#5
0
        public IActionResult About()
        {
            var model = new AuthorListViewModel()
            {
                Settings = _settings, Authors = _repositories.Authors.Get()
            };

            return(View(model));
        }
        public IEnumerable <AuthorListViewModel> GetBestsellerAuthors()
        {
            IEnumerable <Author> authors = _context.Authors.Include(a => a.Books);

            authors = authors
                      .Where(a => a.Books.Count() >= 3)
                      .OrderByDescending(a => a.Books.Count());
            return(authors.Select(a => AuthorListViewModel.FromAuthor(a)));
        }
示例#7
0
        public IActionResult Index()
        {
            var vm = new AuthorListViewModel();

            using (var pubs = new PubsEntities())
            {
                vm.Authors = pubs.Authors.ToArray();
            }
            return(View(vm));
        }
示例#8
0
        public IActionResult Index()
        {
            List <Author>       A  = Repo.GetAllAuthors();
            AuthorListViewModel VM = new AuthorListViewModel();

            foreach (Author a in A)
            {
                VM.Authors.Add(Converter.AuthorToAuthorViewModel(a));
            }
            return(View(VM));
        }
示例#9
0
        public ActionResult AuthorsList()
        {
            var AuthorViewModel = new AuthorListViewModel();

            var authors_lastadd = db.Authors.OrderBy(x => x.AUTHOR_ID).Take(6).ToList();

            AuthorViewModel.Last_Added = authors_lastadd;
            var most_favorite = db.Authors.OrderByDescending(x => x.FAVORITE_COUNT).Take(6).ToList();

            AuthorViewModel.MostFavorite = most_favorite;
            var most_readed = db.Authors.OrderByDescending(x => x.FAVORITE_COUNT).Take(6).ToList();

            AuthorViewModel.MostReaded = most_readed;
            AuthorViewModel.Authors    = db.Authors.Take(10).ToList();
            return(View(AuthorViewModel));
        }
        public async Task <ActionResult> ListAllAuthors()
        {
            var response = (await Cache.GetOrCreateAsync("authors|all", async entry =>
            {
                entry.Value = (await Client.ListAuthorsAsync()).ToList();
                entry.AbsoluteExpiration = DateTimeOffset.Now.AddDays(2);
                return((IEnumerable <Author>)entry.Value);
            })).ToList();

            var model = new AuthorListViewModel
            {
                Authors = response,
                Count   = response.Count
            };

            return(View(model));
        }
示例#11
0
        public ActionResult AuthorsList(string search)
        {
            var AuthorViewModel = new AuthorListViewModel();

            var authors_lastadd = db.Authors.OrderBy(x => x.AUTHOR_ID).Take(6).ToList();

            AuthorViewModel.Last_Added = authors_lastadd;
            var most_favorite = db.Authors.OrderByDescending(x => x.FAVORITE_COUNT).Take(6).ToList();

            AuthorViewModel.MostFavorite = most_favorite;
            var most_readed = db.Authors.OrderByDescending(x => x.FAVORITE_COUNT).Take(6).ToList();

            AuthorViewModel.MostReaded = most_readed;
            var authors = db.Authors.Where(x => x.AUTHOR_NAME.Contains(search) || x.AUTHOR_LASTNAME.Contains(search)).ToList();

            AuthorViewModel.Authors = authors;
            return(View(AuthorViewModel));
        }
        public IEnumerable <AuthorListViewModel> GetAuthors([FromQuery] string search, [FromQuery] bool?isAlive)
        {
            Console.WriteLine($"search is {search}");
            IEnumerable <Author> authors = _context.Authors.Include(a => a.Books);

            if (!string.IsNullOrEmpty(search))
            {
                authors = authors.Where(a => a.Name.Contains(search, StringComparison.InvariantCultureIgnoreCase));
            }

            // [sw] whether I should filter based on status among the living at all
            if (isAlive.HasValue)
            {
                authors = authors.Where(a => a.DateOfDeath.HasValue != isAlive);
            }


            return(authors.Select(a => AuthorListViewModel.FromAuthor(a)));
        }
示例#13
0
 public AuthorListPage(AuthorListViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
        public IEnumerable <AuthorListViewModel> GetAuthors()
        {
            var authors = _context.Authors.Include(a => a.Books);

            return(authors.Select(a => AuthorListViewModel.FromAuthor(a)));
        }