public async Task <IActionResult> DeleteConfirmed(Task task) { _uow.Context.Tasks.Remove(task); await _uow.Context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("TaskId,AddedDay,AddedTime,FinishTime,TaskContent")] Task task) { var user = _userManager.GetUserAsync(HttpContext.User); if (user.Id == id) { return(View("Error")); } if (ModelState.IsValid) { try { task.ApplicationUsers_Email = user.Result.Email; _uow.Context.Update(task); await _uow.Context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (user == null) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(task)); }
public void SendMail(Task task) // czy tworzy się metody asynchroniczne dla void ? { MailManager _mailManager = new MailManager(); MailSender _mailSender = new MailSender(); var message = _mailManager.CreateMessage("Task reminder", "*****@*****.**", "Babel", task.ApplicationUsers_Email, "Task to do on: " + task.FinishTime.ToString(), task.TaskContent); _mailSender.SendMessage(message); }
public async Task <IActionResult> Create([Bind("AddedDay, FinishDay, FinishTime, TaskContent")] Task task) { if (ModelState.IsValid) { var user = _userManager.GetUserAsync(HttpContext.User); task.ApplicationUsers_Email = user.Result.Email; task.AddTime = DateTime.Now; var setDay = task.FinishDay.AddDays(-1); var setTime = task.FinishTime; var SendData = new DateTime(setDay.Year, setDay.Month, setDay.Day, setTime.Hour, setTime.Minute, setTime.Second); BackgroundJob.Schedule(() => SendMail(task), SendData);// TimeSpan.FromSeconds(1)); _uow.Context.Tasks.Add(task); await _uow.Context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(task)); }