public async Task <ActionResult> Create(ExaminationPlanEditViewModel model) { if (!this.ModelState.IsValid) { return(View(model)); } var plan = new ExaminationPlan(model.Title, model.Address) { AttendanceConfirmationExpiresAt = model.AttendanceConfirmationExpiresAt, Notes = model.Notes, }; try { await this.examManager.CreateAsync(plan); return(RedirectToAction("Detail", new { id = plan.Id })); } catch (Exception ex) { this.ModelState.AddModelError("", ex.Message); return(View(model)); } }
/// <summary> /// /// </summary> /// <param name="plan"></param> /// <returns></returns> public async Task UpdateAsync(ExaminationPlan plan) { if (plan == null) { throw new ArgumentNullException(nameof(plan)); } this.db.Entry(plan).State = EntityState.Modified; await this.db.SaveChangesAsync(); }
/// <summary> /// /// </summary> /// <param name="plan"></param> /// <returns></returns> public async Task DeleteAsync(ExaminationPlan plan) { if (plan == null) { throw new ArgumentNullException(nameof(plan)); } this.set.Remove(plan); await this.db.SaveChangesAsync(); }
/// <summary> /// /// </summary> /// <param name="plan"></param> /// <returns></returns> public async Task NotifyPlanPublishedAsync(ExaminationPlan plan) { if (plan == null) { throw new ArgumentNullException(nameof(plan)); } foreach (var candidate in plan.Candidates) { await this.smsService.SendAsync(new string[] { candidate.Person.Mobile }, examinationPlanPublisedMessageTemplateId, candidate.Person.DisplayName); } }
/// <summary> /// 通知准考证发放。 /// </summary> /// <param name="plan"></param> /// <returns></returns> public async Task NotifyAdmissionTicketReleasedAsync(ExaminationPlan plan) { if (plan == null) { throw new ArgumentNullException(nameof(plan)); } foreach (var candidate in plan.Candidates.Where(c => c.Attendance.HasValue && c.Attendance.Value == true)) { await this.smsService.SendAsync(new string[] { candidate.Person.Mobile }, ticketReleasedMessageTemplateId, candidate.Person.DisplayName); } }