Exemplo n.º 1
0
        public IActionResult CreateLesson(string courseId)
        {
            var viewModel = new LessonInputModel
            {
                CourseId = courseId,
            };

            return(this.View(viewModel));
        }
Exemplo n.º 2
0
        [HttpPost]    // api/lesson
        public async Task <ActionResult <int> > AddOrUpdateLesson([FromBody] LessonInputModel inputModel)
        {
            Lesson lesson = LessonMapper.ToDataModel(inputModel);

            if (lesson == null)
            {
                return(BadRequest("Model is empty"));
            }
            return(Ok(await lessonStorage.AddOrUpdateLesson(lesson)));
        }
Exemplo n.º 3
0
        public ActionResult Edit(LessonInputModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var currentUserId  = this.UserProfile.Id;
                var updatedArticle = this.Mapper.Map <Lesson>(model);

                this.lessons.Update(model.Id, updatedArticle);

                return(this.RedirectToAction("Lesson", "School", new { area = "", id = model.Id }));
            }

            return(this.View(model));
        }
        public ActionResult Edit(LessonInputModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var currentUserId = this.UserProfile.Id;
                var updatedArticle = this.Mapper.Map<Lesson>(model);

                this.lessons.Update(model.Id, updatedArticle);

                return this.RedirectToAction("Lesson", "School", new { area = "", id = model.Id });
            }

            return this.View(model);
        }
Exemplo n.º 5
0
        [HttpPost("with-journals")] //api/lesson/with-journals
        public async Task <ActionResult <int?> > AddLessonWithJournals([FromBody] LessonInputModel inputModel)
        {
            if (inputModel == null)
            {
                return(BadRequest("Model is empty"));
            }

            Lesson dataModel = LessonMapper.ToDataModel(inputModel);

            if (dataModel == null)
            {
                return(BadRequest("Failed to add an object"));
            }

            return(Ok(await lessonStorage.AddJournals(dataModel)));
        }
Exemplo n.º 6
0
        public ActionResult Create(LessonInputModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var currentUserId = this.UserProfile.Id;
                var newArticle    = this.Mapper.Map <Lesson>(model);

                newArticle.TrainerId = currentUserId;

                var result = this.lessons.Create(newArticle);

                return(this.RedirectToAction("Lesson", "School", new { area = "", id = result }));
            }

            return(this.View(model));
        }
        public ActionResult Create(LessonInputModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                var currentUserId = this.UserProfile.Id;
                var newArticle = this.Mapper.Map<Lesson>(model);

                newArticle.TrainerId = currentUserId;

                var result = this.lessons.Create(newArticle);

                return this.RedirectToAction("Lesson", "School", new { area = "", id = result });
            }

            return this.View(model);
        }
Exemplo n.º 8
0
        public IActionResult Add(LessonInputModel input)
        {
            if (!ModelState.IsValid)
            {
                return(View(input));
            }

            var lesson = _mapper.Map <Lesson>(input);

            _lessonService.AddLesson(lesson);
            _lessonService.SaveChanges();

            _logger.LogInformation("{user} added lesson {lesson}", User.Identity.Name, lesson.Id);

            return(RedirectToAction("View", new { id = lesson.Id }));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> CreateLesson(LessonInputModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            var lesson = await this.lessonsService.CreateLessonAsync(inputModel.Name, inputModel.Description, inputModel.CourseId);

            var viewModel = new SegmentInputModel
            {
                LessonId           = lesson.Id,
                PlaceInLessonOrder = inputModel.PlaceInOrder,
                CourseId           = inputModel.CourseId,
            };

            return(this.RedirectToAction("CreateSegment", "Segments", viewModel));
        }
Exemplo n.º 10
0
 public MarkCourseSelfCompletedModel ViewLesson(LessonInputModel lessonInputModel)
 {
     return(Post <MarkCourseSelfCompletedModel, LessonInputModel>("mod_lesson_view_lesson", lessonInputModel));
 }
Exemplo n.º 11
0
 public PagesModel GetPages(LessonInputModel lessonInputModel)
 {
     return(Post <PagesModel, LessonInputModel>("mod_lesson_get_pages", lessonInputModel));
 }
Exemplo n.º 12
0
 public LessonModel GetLesson(LessonInputModel lessonInputModel)
 {
     return(Post <LessonModel, LessonInputModel>("mod_lesson_get_lesson", lessonInputModel));
 }