public async Task <List <Category> > GetAllWithBlogs() { using var context = new BlogAppContext(); return(await context.Categories.OrderByDescending(I => I.Id).Include(I => I.BlogCategories) .Include(I => I.SubCategories). ToListAsync()); }
public async Task Create(T entity) { using var context = new BlogAppContext(); await context.AddAsync(entity); await context.SaveChangesAsync(); }
// // GET: /Users/Edit/5 public ActionResult Edit(int id) { using (BlogAppContext context = new BlogAppContext()) { Repository <User> r = new Repository <User>(context); var model = r.Get(a => a.Id == id); return(View(model)); } }
public UnitOfWork(Repository <Blog> blogRepository, Repository <Category> categoryRepository, Repository <Comment> commentRepository, Repository <Role> roleRepository, Repository <User> userRepository) { _blogRepository = blogRepository; _categoryRepository = categoryRepository; _commentRepository = commentRepository; _roleRepository = roleRepository; _userRepository = userRepository; _context = new BlogAppContext(); }
// // GET: /Users/ public ActionResult Index() { //var list = new IEnumerable<User>(); using (BlogAppContext context = new BlogAppContext()) { context.Database.CreateIfNotExists(); Repository <User> r = new Repository <User>(context); var list = r.GetAllList(); return(View(list.ToList())); } //return View(); }
public PostsController(BlogAppContext context, IPostService postService, UserManager <ApplicationUser> userManager, ICategoryService categoryService, IUserService userService, IUserCategoryService userCategoryService ) { _postService = postService; _categoryService = categoryService; _context = context; _userManager = userManager; _userService = userService; _userCategoryService = userCategoryService; }
public ActionResult Edit(int id, User model) { try { // TODO: Add update logic here using (BlogAppContext context = new BlogAppContext()) { Repository <User> r = new Repository <User>(context); r.Update(model); context.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(User model) { try { using (BlogAppContext context = new BlogAppContext()) { Repository <User> r = new Repository <User>(context); r.Insert(model); context.SaveChanges(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public CategoryRepoImpl(BlogAppContext context) { _context = context; }
public HomePageRepoImpl(BlogAppContext context) { _context = context; }
public EFAppUserRepository(BlogAppContext context) : base(context) { }
// TKey represents the column public async Task <List <T> > GetAllWithFilterDescending <TKey>(Expression <Func <T, bool> > filter, Expression <Func <T, TKey> > keySelector) { using var context = new BlogAppContext(); return(await context.Set <T>().Where(filter).OrderByDescending(keySelector).ToListAsync()); }
public async Task Update(T entity) { using var context = new BlogAppContext(); context.Update(entity); await context.SaveChangesAsync(); }
public async Task <T> GetByFilter(Expression <Func <T, bool> > tableFilter) { using var context = new BlogAppContext(); return(await context.Set <T>().FirstOrDefaultAsync(tableFilter)); }
public EFBlogRepository(BlogAppContext context) : base(context) { _context = context; }
public EFGenericRepository(BlogAppContext context) { _context = context; }
public PostBLL(BlogAppContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public Repository(BlogAppContext context) { m_Context = context; m_DbSet = m_Context.Set <T>(); }
public PostRepoImpl(BlogAppContext context) { _context = context; }
public UserRepoImpl(BlogAppContext context) { _context = context; }
public EFCommentRepository(BlogAppContext context) : base(context) { _context = context; }
public AdminRepoImpl(BlogAppContext context) { _context = context; }
public async Task <List <T> > GetAllByFilter(Expression <Func <T, bool> > tableFilter) { using var context = new BlogAppContext(); return(await context.Set <T>().Where(tableFilter).ToListAsync()); }
public Repository(BlogAppContext context) { _context = context; _dbSet = _context.Set <T>(); }
public EFCategoryRepository(BlogAppContext context) : base(context) { _context = context; }
public UnitOfWork() { _context = new BlogAppContext(); }
public async Task <List <T> > GetAll() { using var context = new BlogAppContext(); return(await context.Set <T>().ToListAsync()); }
public CategoryRepository(BlogAppContext context) { _context = context; }
public async Task <T> FindById(int id) { using var context = new BlogAppContext(); return(await context.FindAsync <T>(id)); }