Exemplo n.º 1
0
 public virtual async Task <T> GetAsync(params object[] key)
 {
     using (var db = new ExpenseMgrContext())
     {
         return(await db.Set <T>().FindAsync(key));
     }
 }
Exemplo n.º 2
0
 public virtual async Task <IEnumerable <T> > GetAllAsync()
 {
     using (var db = new ExpenseMgrContext())
     {
         return(await db.Set <T>().ToListAsync());
     }
 }
Exemplo n.º 3
0
 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()));
     };
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        // 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();
        }