public async Task PickStudyDate(StudyDateViewModel model) { var user = await userManager.FindByIdAsync(model.UserId); user.StudyDate = model.StudyDate.AddDays(1); appDbContext.Entry(user).State = EntityState.Modified; appDbContext.SaveChanges(); if (user.StudyDate.AddMonths(-1) >= DateTime.Now) { BackgroundJob.Schedule( () => SendNotification(user), user.StudyDate.AddMonths(-1)); } if (user.StudyDate.AddDays(-7) >= DateTime.Now) { BackgroundJob.Schedule( () => SendNotification(user), user.StudyDate.AddDays(-7)); } if (user.StudyDate.AddDays(-1).Date + new TimeSpan(7, 0, 0) >= DateTime.Now) { BackgroundJob.Schedule( () => SendNotification(user), user.StudyDate.AddDays(-1).Date + new TimeSpan(7, 0, 0)); } }
public async Task <IActionResult> PickStudyDate([FromBody] StudyDateViewModel model) { if (!ModelState.IsValid) { return(BadRequest(model)); } await accountService.PickStudyDate(model); return(Ok()); }