public async Task <ActionResponse> AddLesson(int courseId, Lesson lesson)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var access = await _userService.AuthorizeCourse(userId, courseId);

            if (access)
            {
                var res = await _lessonService.AddLesson(courseId, lesson);

                return(new ActionResponse(res != null));
            }
            else
            {
                return(new ActionResponse(false, "You do not have right to add lesson here"));
            }
        }
Beispiel #2
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 }));
        }