Exemple #1
0
        public List <Account> Get()
        {
            QuanLyHocSinhSqlContext context = new QuanLyHocSinhSqlContext();
            var test = context.Account.Take(5).ToList();

            if (test.Count == 5)
            {
                List <Account> result = new List <Account>();
                result.Add(test[0]);
                result.Add(test[1]);
                result.Add(test[2]);
                result.Add(test[3]);
                result.Add(test[4]);

                return(result);
            }
            else
            {
                return(null);
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        //public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        //{
        //    if (env.IsDevelopment())
        //    {
        //        app.UseDeveloperExceptionPage();
        //    }

        //    app.UseMvc();
        //}
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, QuanLyHocSinhSqlContext context)
        {
            loggerFactory.AddConsole(_config.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseCors(options => options.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials());

            app.UseAuthentication();

            app.UseMvc();
            DbInitializer.Initialize(context);
        }
 public static void Initialize(QuanLyHocSinhSqlContext context)
 {
     context.Database.EnsureCreated();
 }
 public AccountService()
 {
     _context = new QuanLyHocSinhSqlContext();
 }