public async Task <IActionResult> Verwijder(string id)
        {
            if (!int.TryParse(id, out var intId))
            {
                return(BadRequest());
            }
            await GeplandeTelMomentenManager.DeleteMoment(intId);

            return(Ok());
        }
Beispiel #2
0
        public async Task <IActionResult> Index()
        {
            var telMomenten = await GeplandeTelMomentenManager.GetGeplandeMomenten();

            if (TopScoreCache == null)
            {
                await CreateTopScoreCache();
            }
            var topscores = TopScoreCache.Take(10).ToList();

            return(View(new HomeModel {
                TopScores = topscores, TelMomenten = telMomenten
            }));
        }
        public async Task <IActionResult> Index()
        {
            var errors = TempData.Get <List <string> >("errors");

            if (errors != null)
            {
                foreach (var error in errors)
                {
                    ModelState.AddModelError("", error);
                }
            }
            using (var db = new ApplicationDbContext())
            {
                var telMomenten = await GeplandeTelMomentenManager.GetGeplandeMomenten();

                return(View(new GeplandeTelMomentenModel
                {
                    Geplande = telMomenten
                }));
            }
        }
 public async Task <IActionResult> Opslaan(GeplandeTelMomentenModel model)
 {
     if (model.Nieuw != null)
     {
         var fouten = new List <string>();
         if (model.Nieuw.Tijd == default(DateTime))
         {
             fouten.Add("Tijd mag niet leeg zijn");
         }
         if (string.IsNullOrWhiteSpace(model.Nieuw.Reden))
         {
             fouten.Add("Reden mag niet leeg zijn");
         }
         if (fouten.Count > 0)
         {
             TempData.Put("errors", fouten);
             return(RedirectToAction("Index"));
         }
         await GeplandeTelMomentenManager.AddTelMoment(model.Nieuw);
     }
     return(RedirectToAction("Index"));
 }
Beispiel #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, IServiceProvider serviceProvider)
        {
            IsDevelopment = env.IsDevelopment();
            //app.UsePathBase("/beursspel");
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }



            app.UseSession();
            app.UseHangfireServer();

            app.UseStaticFiles();

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            app.UseAuthentication();



            var types = Assembly.GetExecutingAssembly().GetTypes()
                        .Where(y => typeof(IRecurringTask).IsAssignableFrom(y));

            foreach (var type in types)
            {
                if (type.IsInterface)
                {
                    continue;
                }
                var o = (IRecurringTask)Activator.CreateInstance(type);
                if (o.Enabled)
                {
                    RecurringJob.AddOrUpdate(() => o.ExecuteAsync(), o.Cron, TimeZoneInfo.Local);
                }
            }

            app.UseMiddleware <CheckIfOpenMiddleware>();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            var task = CreateRoles(serviceProvider);

            task.Wait();
            var options = new DashboardOptions
            {
                Authorization = new [] { new HangfireAuthentication() }
            };

            app.UseHangfireDashboard("/hangfire", options);

            using (var context = new ApplicationDbContext())
            {
                context.Database.Migrate();
            }

            var t1 = GeplandeTelMomentenManager.CheckMarktSluiting();

            t1.Wait();
            var t2 = GeplandeTelMomentenManager.CheckMarktOpening();

            t2.Wait();
        }
Beispiel #6
0
 public async Task ExecuteAsync()
 {
     await GeplandeTelMomentenManager.CheckMarktOpening();
 }