Example #1
0
        public bool UpdateLessonPlan(LessonPlanEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var lessonPlan = ctx.LessonPlans.Single(m => m.LessonPlanId == model.LessonPlanId);
                lessonPlan.LessonPlanId   = model.LessonPlanId;
                lessonPlan.LessonPlanName = model.LessonPlanName;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, LessonPlanEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.CourseId != id)
            {
                ModelState.AddModelError("", "ID mismatch");
                return(View(model));
            }

            if (CreateLessonPlanService().UpdateLessonPlan(model))
            {
                TempData["Save Result"] = "Lesson Plan updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Error editing lesson plan");
            return(View(model));
        }