public async Task <ActionResult> Edit([Bind(Include = "Id,Name,IconURL,IsPreviewable,PreLessonId,PostLessonId,RecLog")] AssessmentItem assessmentItem) { if (ModelState.IsValid) { var selectedAssessmentItem = await db.AssessmentItems.FirstOrDefaultAsync(it => it.Id == assessmentItem.Id); if (selectedAssessmentItem == null) { return(View("Error")); } selectedAssessmentItem.Name = assessmentItem.Name; selectedAssessmentItem.IsPreviewable = assessmentItem.IsPreviewable; var IconUrl = ExtraContentType.PreAssessment.ToString(); selectedAssessmentItem.IconURL = ControllerHelper.ConvertToIconUrl(IconUrl); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Lessons", new { @id = assessmentItem.PreLessonId })); } return(View(assessmentItem)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,IconURL,IsPreviewable,PreLessonId,PostLessonId,RecLog")] AssessmentItem assessmentItem) { if (ModelState.IsValid) { var lesson = await db.Lessons.FirstOrDefaultAsync(it => it.Id == assessmentItem.PreLessonId); if (lesson == null || lesson.RecLog.DeletedDate.HasValue) { return(View("Error")); } assessmentItem.Order = lesson.PreAssessments.Where(it => !it.RecLog.DeletedDate.HasValue).Count() + 1; assessmentItem.RecLog.CreatedDate = DateTime.Now; var IconUrl = ExtraContentType.PreAssessment.ToString(); assessmentItem.IconURL = ControllerHelper.ConvertToIconUrl(IconUrl); db.AssessmentItems.Add(assessmentItem); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Lessons", new { @id = assessmentItem.PreLessonId })); } return(View(assessmentItem)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,IconURL,Description,IsPreviewable,ContentType,ContentURL,TeacherLessonId,StudentLessonId,RecLog")] LessonItem lessonItem) { if (ModelState.IsValid) { var lesson = await db.Lessons.FirstOrDefaultAsync(it => it.Id == lessonItem.TeacherLessonId); if (lesson == null || lesson.RecLog.DeletedDate.HasValue) { return(View("Error")); } lessonItem.Order = lesson.TeacherLessonItems.Where(it => !it.RecLog.DeletedDate.HasValue).Count() + 1; lessonItem.RecLog.CreatedDate = DateTime.Now; var IconUrl = ExtraContentType.Teacher.ToString(); lessonItem.IconURL = ControllerHelper.ConvertToIconUrl(IconUrl); db.LessonItems.Add(lessonItem); db.SaveChanges(); return(RedirectToAction("Details", "Lessons", new { @id = lessonItem.TeacherLessonId })); } return(View(lessonItem)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,IconURL,Description,IsPreviewable,ContentType,ContentURL,TeacherLessonId,StudentLessonId,RecLog")] LessonItem lessonItem) { if (ModelState.IsValid) { var selectedLessonItem = await db.LessonItems.FirstOrDefaultAsync(it => it.Id == lessonItem.Id); if (selectedLessonItem == null) { return(View("Error")); } selectedLessonItem.Name = lessonItem.Name; selectedLessonItem.Description = lessonItem.Description; selectedLessonItem.IsPreviewable = lessonItem.IsPreviewable; selectedLessonItem.ContentType = lessonItem.ContentType; selectedLessonItem.ContentURL = lessonItem.ContentURL; selectedLessonItem.IconURL = ControllerHelper.ConvertToIconUrl(lessonItem.ContentType); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Lessons", new { @id = lessonItem.StudentLessonId })); } return(View(lessonItem)); }