Blog Posts for: Aspnetmvc

Resolve your DbContext as an interface using the ASP.NET 5 dependency injection framework

19 May 2015

When developing ASP.NET applications, I prefer to have my database context implement an interface and then inject the interface, as this allows me to more easily mock the database context during unit tests. So in a typical application, I would do something like this: public interface IApplicationDbContext { DbSet<Episode> Episodes { get; set; } DbSet<ApplicationUser> Users { get; set; } int SaveChanges(); Task<int> SaveChangesAsync(CancellationToken cancellationToken); } public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplicationDbContext { public virtual DbSet<Episode> Episodes { get; set; } public ApplicationDbContext() { .

2 Approaches when rendering a list using the Bootstrap grid system

12 May 2015

Introduction Rendering a list of items in ASP.NET MVC inside a grid (HTML Table) is straight forward and easy. You simply but everything inside an HTML Table tag and generate table rows for each item in the list you want to render. But what to do when you want to render it as a list of rows and columns? Well, Bootstrap has a grid system which allows you to layout items as rows and columns.