public virtual async Task <T> GetAsync(params object[] key) { using (var db = new ExpenseMgrContext()) { return(await db.Set <T>().FindAsync(key)); } }
public virtual async Task <IEnumerable <T> > GetAllAsync() { using (var db = new ExpenseMgrContext()) { return(await db.Set <T>().ToListAsync()); } }
public virtual async Task <IEnumerable <T> > FilterAsync(Func <T, bool> criteria) { using (var db = new ExpenseMgrContext()) { return(await Task.FromResult(db.Set <T>().Where(criteria).ToList())); }; }
public virtual async Task <T> AddAsync(T tEntity) { using (var db = new ExpenseMgrContext()) { await db.Set <T>().AddAsync(tEntity); return((await db.SaveChangesAsync()) == 1 ? tEntity : null); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ExpenseMgrContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("*"); app.UseMvc(); StaticServiceResolver.Register(app.ApplicationServices); context.Database.Migrate(); }