예제 #1
0
 public UsersController(
     BookStoresDBContext context,
     IOptions <JWTSettings> jWTSettings)
 {
     _context     = context;
     _jWTSettings = jWTSettings.Value;
 }
예제 #2
0
        public IEnumerable <Author> Get()
        {
            using (var context = new BookStoresDBContext())
            {
                //Get all authors
                //return context.Author.ToList();

                //Add author
                //Author author = new Author();
                //author.FirstName = "Kaustubh";
                //author.LastName = "Sonar";
                //author.EmailAddress = "*****@*****.**";
                //context.Author.Add(author);
                //context.SaveChanges();

                //Update
                //Author author1 = context.Author.Where(auth => auth.FirstName == "Kaustubh").FirstOrDefault();
                //author1.Phone = "123-131-131";
                //context.SaveChanges();

                //delete
                //Author author2 = context.Author.Where(auth => auth.FirstName == "Kaustubh").FirstOrDefault();
                //context.Remove(author2);
                //context.SaveChanges();

                //Get by Id
                return(context.Authors.Where(auth => auth.FirstName == "Kaustubh").ToList());
            }
        }
예제 #3
0
        public IEnumerable <Author> Get()
        {
            using (var _context = new BookStoresDBContext())  // Instans
            {
                //get all authors
                //return context.Author.ToList();

                // add an author in my database
                //Author author = new Author(); // add an author in my database
                //author.FirstName = "John"; // add an author in my database
                //author.LastName = "Smith"; // add an author in my database

                //context.Author.Add(author); // add an author in my database

                Author author = _context.Author.Where(auth => auth.FirstName == "John").FirstOrDefault();
                author.Phone = "777-777-7777";

                _context.SaveChanges(); // add an author in my database



                // get author by id
                return(_context.Author.Where(auth => auth.FirstName == "John").ToList());
            }
        }
예제 #4
0
 public BasicAuthenticationHandlers(
     IOptionsMonitor <AuthenticationSchemeOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     ISystemClock clock, BookStoresDBContext context) : base(options, logger, encoder, clock)
 {
     _context = context;
 }
예제 #5
0
        public IEnumerable <Publisher> Get()
        {
            //CRUD
            using (var _context = new BookStoresDBContext())
            {
                //Publisher publisher = new Publisher();
                //publisher.PublisherName = "Egmont Book";

                //_context.Publishers.Add(publisher);
                //_context.SaveChanges();

                Publisher publisher = _context.Publishers.FirstOrDefault();
                //publisher.PublisherName = "Egmond Books";
                _context.Publishers.Remove(publisher);
                _context.SaveChanges();

                return(_context.Publishers.ToList());
            }
        }
예제 #6
0
        public IEnumerable <Publisher> Get()
        {
            using (var _context = new BookStoresDBContext())
            {
                //Publisher publisher = new Publisher();
                //publisher.PublisherName = "Max Payne";
                //_context.Publishers.Add(publisher);
                //_context.SaveChanges();

                //Update first publisher always.........................................
                //Publisher publisher = _context.Publishers.FirstOrDefault();
                //publisher.PublisherName = "Max Payne II";
                //_context.SaveChanges();

                //Remove the first publisher in the list always......................................
                Publisher publisher = _context.Publishers.FirstOrDefault();
                _context.Publishers.Remove(publisher);
                _context.SaveChanges();


                return(_context.Publishers.ToList());
            }
        }
예제 #7
0
        public IEnumerable <Author> Get()
        {
            using (var context = new BookStoresDBContext())
            {
                // Get All
                // return context.Author.ToList();

                // Add an author

                /*Author author = new Author();
                 *
                 * author.FirstName = "John";
                 * author.LastName = "Smith";
                 * author.Phone = "123-456-7890";
                 * author.State = "FL";
                 * author.Zip = "12345";
                 *
                 * context.Author.Add(author);
                 *
                 * context.SaveChanges();*/

                Author author = context.Author.Where(auth => auth.AuthorId == 25).FirstOrDefault();

                /*               author.Phone = "111-111-1111";
                 *
                 *             context.Author.Update(author);
                 *
                 *             context.SaveChanges();*/
                // Get bi Id
                // return context.Author.Where(auth => auth.AuthorId == 4).ToList();

                context.Author.Remove(author);
                context.SaveChanges();

                return(context.Author.ToList());
            }
        }
        public IEnumerable <Author> Get()
        {
            using (var context = new BookStoresDBContext())
            {
                // Get all authors ******************
                return(context.Authors.ToList());


                // Get author by id ******************
                //return context.Authors.Where(auth => auth.AuthorId == 1).ToList();


                // To add an author ******************
                //Author author = new Author();
                //author.FirstName = "John";
                //author.LastName = "Smith";

                //context.Authors.Add(author);

                //context.SaveChanges();
                // return context.Authors.Where(auth => auth.FirstName == "John").ToList();


                // To update the author ******************
                //Author author = context.Authors.Where(auth => auth.FirstName == "John").FirstOrDefault();
                //author.Phone = "777-777-7777";
                //context.SaveChanges();
                // return context.Authors.Where(auth => auth.FirstName == "John").ToList();


                // To remove author
                //Author author = context.Authors.Where(auth => auth.FirstName == "John").FirstOrDefault();
                //context.Authors.Remove(author);
                //context.SaveChanges();
                //return context.Authors.Where(auth => auth.FirstName == "John").ToList();
            }
        }
예제 #9
0
 public PublishersController(BookStoresDBContext context)
 {
     _context = context;
 }
예제 #10
0
 public StoresController(BookStoresDBContext context)
 {
     _context = context;
 }
예제 #11
0
 public AuthorsController(BookStoresDBContext context)
 {
     this._context = context;
 }
예제 #12
0
 public AuthorController(BookStoresDBContext context)
 {
     _context = context;
 }
예제 #13
0
 public UsersController(BookStoresDBContext context, JWTSettings jwtSettings)
 {
     _context     = context;
     _jWTSettings = jwtSettings;
 }
예제 #14
0
 public BooksController(BookStoresDBContext context, IDistributedCache distributedCache)
 {
     _context = context;
     this.distributedCache = distributedCache;
 }
예제 #15
0
 public AuthorController(BookStoresDBContext bookStoresDBContext)
 {
     _bookStoresDBContext = bookStoresDBContext;
 }
예제 #16
0
 public BooksAuthorsController(BookStoresDBContext context)
 {
     _context = context;
 }