Ejemplo n.º 1
0
        public ActionResult CreateLesson(CreateLesson model)
        {
            ViewBag.LinkTypes = db.RunListProcedure<LinkType>("[SelectAllLinkTypes]", new { });
            if (!ModelState.IsValid)
            {
                return View("CreateLesson", model);
            }
            else
            {
                string username = User.Identity.Name;
                User user;
                try
                {
                    user = db.RunProcedure<User>("SelectUserByName", new { UserName = username });
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "Please Login to submit Course.");
                    if (Request.IsAjaxRequest())
                    {
                        return PartialView(model);
                    }
                    else
                    {
                        return View(model);
                    }

                }
                Lesson lesson = db.RunListProcedure<Lesson>("InsertLesson", new
                {
                    courseId = model.CourseId,
                    userId = user.UserId,
                    lessonName = model.LessonName,
                    link = model.Link,
                    lessonText = model.LessonText??"",
                    LinkTypeId = model.LinkTypeId,
                    SectionName = !string.IsNullOrEmpty(model.SectionName) ? model.SectionName : null
                }).First();
                return RedirectToAction("Lesson", "Apps", new {id = lesson.LessonId});
            }
        }
Ejemplo n.º 2
0
        public ActionResult CreateLesson()
        {
            int id = Convert.ToInt32(this.ControllerContext.RouteData.Values["id"]);
            ViewBag.courseId = id;
            CreateLesson model = new CreateLesson() { CourseId = id };
            ViewBag.LinkTypes = db.RunListProcedure<LinkType>("[SelectAllLinkTypes]", new { });

            return View(model);
        }