public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, BookDBContext context) { _userManager = userManager; _signInManager = signInManager; _context = context; }
public IdentityLoginController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, BookDBContext bookDBContext) { this.userManager = userManager; this.signInManager = signInManager; this.bookDBContext = bookDBContext; }
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"); } }
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; }
// 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"); } }
// GET: All books public JsonResult GetAllBooks() { using (BookDBContext contextObj = new BookDBContext()) { var bookList = contextObj.book.ToList(); return(Json(bookList, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAllBooks() { using (BookDBContext objContext = new BookDBContext()) { var booklist = objContext.book.ToList(); return(Json(booklist, JsonRequestBehavior.AllowGet)); } }
//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)); } }
// 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(); }
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)); } }
protected virtual void UpdateDatabase() { using (var db = new BookDBContext()) { int index = 1; foreach (S4452232 book in db.S4452232) { book.Index = index; index++; } db.SaveChanges(); } }
// 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(); }
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"); } }
// 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"); } }
// 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(); }
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()); } }
//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"); } }
// 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?}"); }); }
public BookRepository() { context = new BookDBContext(); }
public WishlistDataAccessLayer(BookDBContext dbContext) { _dbContext = dbContext; }
public DocumentResultDataAccessLayer(BookDBContext dbContext) { _dbContext = dbContext; }
public CartDataAccessLayer(BookDBContext dbContext) { _dbContext = dbContext; }
public CountryRepository(BookDBContext bookDBContext) { _bookDBContext = bookDBContext; }
public Repository(BookDBContext context) { this._context = context; }
public BooksController(BookDBContext context, IBookService book) { _context = context; _addBook = book; }
public BookController(BookDBContext context) { _context = context; }
public BookRepository(BookDBContext context) { this.context = context; }
public BookRepository(BookDBContext bookDBContext) { _bookDBContext = bookDBContext; }
public UserDataAccessLayer(BookDBContext dbContext) { _dbContext = dbContext; }
public CategoryRepository(BookDBContext bookDBContext) { _bookDBContext = bookDBContext; }