// 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.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseHangfireDashboard(); app.UseHangfireServer(); SlackClientTest slackclient = new SlackClientTest(); RecurringJob.AddOrUpdate(() => slackclient.Postmessage(), "0 9 * * *"); }
public ActionResult Create([Bind(Include = "ID,StudentID,ClassID,Date,Late")] SignIn signIn) { if (ModelState.IsValid) { string userID = User.Identity.GetUserId(); //get current userID var user = db.Users.Where(u => u.Id == userID).FirstOrDefault(); //get user var student = db.Students.Where(s => s.UserID == user.Id).FirstOrDefault(); //get the corresponding student //DateTime signInTime = Convert.ToDateTime(signIn.Date.TimeOfDay); signIn.Date = DateTime.Now; signIn.StudentID = student.ID; signIn.ClassID = db.ClassStudents.Where(c => c.StudentID == student.ID).Select(c => c.ClassID).FirstOrDefault(); DateTime lateTime = Convert.ToDateTime("07:15:00"); //if (lateTime <= DateTime.Now) if (DateTime.Now == Convert.ToDateTime("15:32:00")) { SlackClientTest slackClient = new SlackClientTest(); slackClient.TestPostMessage(); } if (signIn.Date.TimeOfDay > lateTime.TimeOfDay) { signIn.Late = true; db.SignIns.Add(signIn); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { signIn.Late = false; db.SignIns.Add(signIn); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } } ViewBag.ClassID = new SelectList(db.Classes, "ID", "Name", signIn.ClassID); ViewBag.StudentID = new SelectList(db.Students, "ID", "FirstName", signIn.StudentID); return(View(signIn)); }