예제 #1
0
        public bool CreateLessonPlan(LessonPlanCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var newLessonPlan = new LessonPlan()
                {
                    CourseId = model.CourseId,
                    //LessonPlanId = model.LessonPlanId,
                    LessonPlanName = model.LessonPlanName
                };

                ctx.LessonPlans.Add(newLessonPlan);
                return(ctx.SaveChanges() > 0);
            }
        }
        public ActionResult Create(LessonPlanCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (CreateLessonPlanService().CreateLessonPlan(model))
            {
                TempData["SaveResult"] = "Lesson Plan created";
                return(RedirectToAction("Index"));
            }

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