public void Post([FromBody] Author item) { BookStoreDataContext db = new BookStoreDataContext(); db.Add(item); db.SaveChanges(); }
public ActionResult <IEnumerable <Category> > Get() { BookStoreDataContext db = new BookStoreDataContext(); var items = db.Categories.ToList(); return(items); }
public ActionResult <Author> Get(int id) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Authors.SingleOrDefault(p => p.AuthorID.Equals(id)); return(item); }
public Author Get(int id) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Authors.Where(p => p.AuthorID.Equals(id)).Single <Author>(); return(item); }
public ActionResult <IEnumerable <Author> > Get() { BookStoreDataContext db = new BookStoreDataContext(); var items = db.Authors.ToList(); return(items); }
public IActionResult Index() { var bookList = db.Books.ToList(); IList <BookViewModel> items = new List <BookViewModel>(); foreach (Book book in bookList) { BookViewModel item = new BookViewModel(); item.ISBN = book.ISBN; item.Title = book.Title; item.Photo = book.Photo; item.PublishDate = book.PublishDate; item.Price = book.Price; item.Quantity = book.Quantity; var category = db.Categories.Where(p => p.CategoryID.Equals(book.CategoryID)).Single <Category>(); item.CategoryName = category.Name; string authorNameList = string.Empty; var booksAuthorsList = db.BooksAuthors.Where(p => p.ISBN.Equals(book.ISBN)); foreach (BookAuthor booksAuthors in booksAuthorsList) { BookStoreDataContext db2 = new BookStoreDataContext(); var author = db2.Authors.Where(p => p.AuthorID.Equals(booksAuthors.AuthorID)).Single <Author>(); authorNameList = authorNameList + author.Name + ", "; } item.AuthorNames = authorNameList.Substring(0, authorNameList.Length - 2); items.Add(item); } return(View(items)); }
public ActionResult <Book> Get(int id) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Books.SingleOrDefault(p => p.ISBN.Equals(id)); return(item); }
public ActionResult <Category> Get(int id) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Categories.SingleOrDefault(p => p.CategoryID.Equals(id)); return(item); }
public IActionResult Template() { BookStoreDataContext db = new BookStoreDataContext(); var test = db.Authors; ViewBag.Authors = db.Authors.Select(p => p); return(View()); }
public void Delete(int id) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Authors.Find(id); db.Authors.Remove(item); db.SaveChanges(); }
public void Put(int id, [FromBody] Author itemNew) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Authors.SingleOrDefault(p => p.AuthorID.Equals(id)); item.Name = itemNew.Name; db.Update(item); db.SaveChangesAsync(); }
public void Put(int id, [FromBody] Book itemNew) { BookStoreDataContext db = new BookStoreDataContext(); var item = db.Books.SingleOrDefault(p => p.ISBN.Equals(id)); item.CategoryID = itemNew.CategoryID; item.Title = itemNew.Title; item.Photo = itemNew.Photo; item.PublishDate = itemNew.PublishDate; item.Price = itemNew.Price; item.Quantity = itemNew.Quantity; db.Update(item); db.SaveChangesAsync(); }
public BookRepository(BookStoreDataContext context) { _db = context; }
// gerando uma dependencia public AutorRepositorio(BookStoreDataContext context) { _context = context; }
public AuthorRepository() { _db = new BookStoreDataContext(); }
public CategoryRepository(BookStoreDataContext context) { _db = context; }
public CategoryRepository(BookStoreDataContext context) { _db = context; _db.Configuration.LazyLoadingEnabled = false; _db.Configuration.ProxyCreationEnabled = false; }
public AuthorRepository(BookStoreDataContext context) { _db = context; }
public AuthorRepository(BookStoreDataContext db) { _db = db; }
public BookRepository() { this._db = new BookStoreDataContext(); }
public LivroRepositorio(BookStoreDataContext context) { _context = context; }