示例#1
0
        [HttpPost("lesson-topic")] // api/lesson/lesson-topic
        public async Task <ActionResult <int> > AddLessonTopic([FromBody] LessonTopicInputModel inputModel)
        {
            LessonTopic lessonTopic = LessonTopicMapper.ToDataModel(inputModel);

            if (lessonTopic == null)
            {
                return(BadRequest("Model is empty"));
            }
            return(Ok(await lessonStorage.AddLessonTopic(lessonTopic)));
        }
示例#2
0
        public async Task Setup()
        {
            listLessonTopic.AddRange(LessonTopicMock.lessonTopicMocks.Select(x => (LessonTopic)x.Clone()));
            listCourse.AddRange(CourseMock.listCourse.Select(x => (Course)x.Clone()));
            listCourseProgram.AddRange(CourseProgramMock.listCourseProgram.Select(x => (CourseProgram)x.Clone()));
            listGroup.AddRange(GroupMock.groupMocks.Select(x => (Group)x.Clone()));
            listLesson.AddRange(LessonMock.lessonMocks.Select(x => (Lesson)x.Clone()));

            for (int i = 0; i < listLessonTopic.Count; i++)
            {
                listCourse[i].Id = await courseStorage.CourseAddOrUpdate(listCourse[i]);

                listCourseProgram[i].CourseId = (int)listCourse[i].Id;
                listCourseProgram[i].Id       = await courseStorage.CourseProgramAddOrUpdate(listCourseProgram[i]);

                listGroup[i].CourseProgramId = (int)listCourseProgram[i].Id;
                listGroup[i].Id = await groupStorage.GroupAddOrUpdate(listGroup[i]);

                listLesson[i].GroupId = (int)listGroup[i].Id;
                listLesson[i].Id      = await lessonStorage.AddOrUpdateLesson(listLesson[i]);

                listLessonTopic[i].LessonId = (int)listLesson[i].Id;
                listLessonTopic[i].Id       = await lessonStorage.AddLessonTopic(listLessonTopic[i]);
            }
        }