Пример #1
0
 public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager,
                          BookDBContext context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _context       = context;
 }
Пример #2
0
 public IdentityLoginController(UserManager <ApplicationUser> userManager,
                                SignInManager <ApplicationUser> signInManager, BookDBContext bookDBContext)
 {
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.bookDBContext = bookDBContext;
 }
Пример #3
0
 public string DeleteBook(string bookid)
 {
     if (!String.IsNullOrEmpty(bookid))
     {
         try
         {
             using (BookDBContext objContext = new BookDBContext())
             {
                 int bookId = Int32.Parse(bookid);
                 var book   = objContext.book.Find(bookid);
                 objContext.book.Remove(book);
                 objContext.SaveChanges();
                 return("Book record deleted successfully");
             }
         }
         catch (Exception ex)
         {
             return("Book details not found");
         }
     }
     else
     {
         return("Invalid operation");
     }
 }
Пример #4
0
        public void InitContext()
        {
            var builder = new DbContextOptionsBuilder <BookDBContext>().UseSqlServer("Server=G3;Database=BookDB;Trusted_Connection=True;MultipleActiveResultSets=true");
            var ctx     = new BookDBContext(builder.Options);

            _ctx = ctx;
        }
Пример #5
0
 // Delete book
 public string DeleteBook(string bookId)
 {
     if (!String.IsNullOrEmpty(bookId))
     {
         try
         {
             int _bookId = Int32.Parse(bookId);
             using (BookDBContext contextObj = new BookDBContext())
             {
                 var _book = contextObj.book.Find(_bookId);
                 contextObj.book.Remove(_book);
                 contextObj.SaveChanges();
                 return("Selected book record deleted sucessfully");
             }
         }
         catch (Exception)
         {
             return("Book details not found");
         }
     }
     else
     {
         return("Invalid operation");
     }
 }
Пример #6
0
 // GET: All books
 public JsonResult GetAllBooks()
 {
     using (BookDBContext contextObj = new BookDBContext())
     {
         var bookList = contextObj.book.ToList();
         return(Json(bookList, JsonRequestBehavior.AllowGet));
     }
 }
Пример #7
0
 public JsonResult GetAllBooks()
 {
     using (BookDBContext objContext = new BookDBContext())
     {
         var booklist = objContext.book.ToList();
         return(Json(booklist, JsonRequestBehavior.AllowGet));
     }
 }
Пример #8
0
 //GET: Book by Id
 public JsonResult GetBookById(string id)
 {
     using (BookDBContext contextObj = new BookDBContext())
     {
         var bookId      = Convert.ToInt32(id);
         var getBookById = contextObj.book.Find(bookId);
         return(Json(getBookById, JsonRequestBehavior.AllowGet));
     }
 }
Пример #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, BookDBContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // context.SeedDataContext();
            app.UseMvc();
        }
Пример #10
0
        public JsonResult GetBookById(string id)
        {
            using (BookDBContext contextobj = new BookDBContext())
            {
                var BookId      = int.Parse(id);
                var getBookById = contextobj.book.Find(BookId);

                return(Json(getBookById, JsonRequestBehavior.AllowGet));
            }
        }
Пример #11
0
 protected virtual void UpdateDatabase()
 {
     using (var db = new BookDBContext()) {
         int index = 1;
         foreach (S4452232 book in db.S4452232)
         {
             book.Index = index;
             index++;
         }
         db.SaveChanges();
     }
 }
Пример #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, BookDBContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            /*app.Run(async (context) =>
             * {
             *  await context.Response.WriteAsync("Hello World!");
             * });*/
            //context.SeedDataContext();
            app.UseMvc();
        }
Пример #13
0
 public string AddBook(Book book)
 {
     if (book != null)
     {
         using (BookDBContext objContext = new BookDBContext())
         {
             objContext.book.Add(book);
             objContext.SaveChanges();
             return("Book record added Successfully");
         }
     }
     else
     {
         return("Invalid book record");
     }
 }
Пример #14
0
 // Add book
 public string AddBook(Book book)
 {
     if (book != null)
     {
         using (BookDBContext contextObj = new BookDBContext())
         {
             contextObj.book.Add(book);
             contextObj.SaveChanges();
             return("Book record added successfully");
         }
     }
     else
     {
         return("Invalid book record");
     }
 }
Пример #15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, BookDBContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            //app.UseEndpoints(endpoints =>
            //{
            //    endpoints.MapGet("/", async context =>
            //    {
            //        await context.Response.WriteAsync("Hello World!");
            //    });
            //});
            context.SeedDataContext();

            app.UseMvc();
        }
Пример #16
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                var db   = new BookDBContext();
                var book = new Book {
                    Title = collection.Get("Title"), ISBN = collection.Get("ISBN"), Author = collection.Get("Author"), Description = collection.Get("Description")
                };
                db.Books.Add(book);
                db.SaveChanges();

                return(RedirectToAction("Index", "Home"));
            }
            catch
            {
                return(View());
            }
        }
Пример #17
0
 //Update Book
 public string UpdateBook(Book book)
 {
     if (book != null)
     {
         using (BookDBContext contextObj = new BookDBContext())
         {
             int  bookId = Convert.ToInt32(book.Id);
             Book _book  = contextObj.book.Where(b => b.Id == bookId).FirstOrDefault();
             _book.Title     = book.Title;
             _book.Author    = book.Author;
             _book.Publisher = book.Publisher;
             _book.Isbn      = book.Isbn;
             contextObj.SaveChanges();
             return("Book record updated successfully");
         }
     }
     else
     {
         return("Invalid book record");
     }
 }
Пример #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, BookDBContext context)
        {
            context.Database.Migrate();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Books}/{action=Index}/{id?}");
            });
        }
Пример #19
0
 public BookRepository()
 {
     context = new BookDBContext();
 }
Пример #20
0
 public WishlistDataAccessLayer(BookDBContext dbContext)
 {
     _dbContext = dbContext;
 }
Пример #21
0
 public DocumentResultDataAccessLayer(BookDBContext dbContext)
 {
     _dbContext = dbContext;
 }
Пример #22
0
 public CartDataAccessLayer(BookDBContext dbContext)
 {
     _dbContext = dbContext;
 }
Пример #23
0
 public CountryRepository(BookDBContext bookDBContext)
 {
     _bookDBContext = bookDBContext;
 }
Пример #24
0
 public Repository(BookDBContext context)
 {
     this._context = context;
 }
Пример #25
0
 public BooksController(BookDBContext context, IBookService book)
 {
     _context = context;
     _addBook = book;
 }
 public BookController(BookDBContext context)
 {
     _context = context;
 }
Пример #27
0
 public BookRepository(BookDBContext context)
 {
     this.context = context;
 }
Пример #28
0
 public BookRepository(BookDBContext bookDBContext)
 {
     _bookDBContext = bookDBContext;
 }
Пример #29
0
 public UserDataAccessLayer(BookDBContext dbContext)
 {
     _dbContext = dbContext;
 }
Пример #30
0
 public BookRepository()
 {
     context = new BookDBContext();
 }
Пример #31
0
 public BookRepository(BookDBContext context)
 {
     this.context = context;
 }
Пример #32
0
 public CategoryRepository(BookDBContext bookDBContext)
 {
     _bookDBContext = bookDBContext;
 }