public async Task <IEnumerable <PublisherViewModel> > GetAll() { var publishers = await m_repository.GetAll(); return((await m_repository.GetAll()) .Select(m => m_automapper.Map <PublisherViewModel>(m))); }
public IActionResult Create() { var bookVM = new BookViewModel() { Publishers = _publisherRepository.GetAll() }; return View(bookVM); }
public IActionResult Index() { if (HttpContext.Session.GetString("user") is null) { Response.Redirect("/admin/login"); } ViewBag.User = HttpContext.Session.GetString("user"); var penalties = _repository.GetAll(); return(View(penalties)); }
public IActionResult GetPublishers() { try { ObjectResult results = new ObjectResult(_publisherRepository.GetAll()) { StatusCode = (int)HttpStatusCode.OK }; Request.HttpContext.Response.Headers.Add("X-Total-Count", _publisherRepository.GetAll().Count().ToString()); return(results); } catch (Exception ex) { return(new StatusCodeResult(500)); } }
public IActionResult Publishers() { IEnumerable <PublisherViewModel> model = publisherRepository.GetAll().Select(s => new PublisherViewModel { PublisherId = s.PublisherId, Name = $"{s.Name}", Region = s.Region, Books = publisherRepository.GetBooksByPublisherId(s.PublisherId), }); return(View(model)); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("=========== List Books by context ==========="); //var books = new List<Book>(); //using (var context = new BookStoreContext()) //{ // books = context.Books.ToList(); //} //books.ForEach(x => Console.WriteLine(x.Title)); Console.WriteLine("=========== List Category by Category Repository ==========="); var categories = _categoryRepository.GetAll(); foreach (var category in categories) { Console.WriteLine(category.Name); } Console.WriteLine("=========== List Author by Author Repository ==========="); var authors = _authorRepository.GetAll(); foreach (var author in authors) { Console.WriteLine(author.Name); } Console.WriteLine("=========== List Publisher by Publisher Repository ==========="); var publishers = _publisherRepository.GetAll(); foreach (var publisher in publishers) { Console.WriteLine(publisher.Name); } Console.WriteLine("=========== Get 10 latest book by Book Repository ==========="); var books = _bookRepository.GetLatestBook(10); foreach (var book in books) { Console.WriteLine(book.Title); } Console.ReadKey(); }
public BookDetailsDTO Get(int id) { Book Book = IBookRepository.Get(id); BookDetailsDTO MyBook = new BookDetailsDTO() { Name = Book.Name, Popularity = Book.Popularity, PublicationYear = Book.PublicationYear }; IEnumerable <BookWriter> MyBookWriters = IBookWriterRepository.GetAll().Where(x => x.BookId == Book.Id); if (MyBookWriters != null) { List <string> BookWriterList = new List <string>(); foreach (BookWriter MyBookWriter in MyBookWriters) { Writer MyWriter = IWriterRepository.GetAll().SingleOrDefault(x => x.Id == MyBookWriter.Id); BookWriterList.Add(MyWriter.Name); } MyBook.WriterName = BookWriterList; } IEnumerable <BookLibrary> MyLibraryBooks = IBookLibraryRepository.GetAll().Where(x => x.BookId == Book.Id); if (MyLibraryBooks != null) { List <string> LibraryBookList = new List <string>(); foreach (BookLibrary MyLibraryBook in MyLibraryBooks) { Library MyLibrary = ILibraryRepository.GetAll().SingleOrDefault(x => x.Id == MyLibraryBook.Id); LibraryBookList.Add(MyLibrary.Name); } MyBook.LibraryName = LibraryBookList; } IEnumerable <BookPublisher> MyPublisherBooks = IBookPublisherRepository.GetAll().Where(x => x.BookId == Book.Id); if (MyPublisherBooks != null) { List <string> PublisherBookList = new List <string>(); foreach (BookPublisher MyPublisherBook in MyPublisherBooks) { Publisher MyPublisher = IPublisherRepository.GetAll().SingleOrDefault(x => x.Id == MyPublisherBook.Id); PublisherBookList.Add(MyPublisher.Name); } MyBook.PublisherName = PublisherBookList; } return(MyBook); }
public void pullSelect() { var author = authorRepository.GetAll() .Where(x => x.isApproved) .Select(x => new { selectname = x.Id, fullname = x.Name + " " + x.Surname }); ViewBag.Types = new SelectList(typeRepository.GetAll(), "TypeId", "Name"); ViewBag.Authors = new SelectList(author, "selectname", "fullname"); ViewBag.Publisher = new SelectList(publisherRepository.GetAll(), "PublisherId", "Name"); ViewBag.Language = new SelectList(languageRepository.GetAll(), "LanguageId", "Name"); }
/// <summary> /// Returns Publishers list. /// </summary> /// <returns></returns> public PublisherOutputDto Publishers() { var output = new PublisherOutputDto(); foreach (var p in _publisherRepository.GetAll()) { output.PublisherDtos.Add(new PublisherDto { Value = p.Id, Name = p.Name }); } return(output); }
public List <Publisher> GetPublishers() { return(_publisherRepository.GetAll()); }
public IEnumerable <Publisher> GetAllPublishers() { return(_publisherRepository.GetAll()); }
public IEnumerable <Publisher> GetAll() { return(_repo.GetAll()); }
public IEnumerable <Publisher> GetPublishers() { return(_publisherRepository.GetAll()); //return _publisherRepository.FindAll(); }
public async Task <List <Publisher> > GetAll() { return(await _publisherRepository.GetAll()); }
public IActionResult Get() { var publisher = _publisherRepository.GetAll(); return(Ok(publisher)); }
public IActionResult List() { return(View(publisherRepository.GetAll())); }