Example #1
0
        private async Task Setup()
        {
            listJournal.AddRange(JournalMock.journalMocks);

            listCity.AddRange(DictionaryMocks.cityMock.Select(m => (City)m.Clone()));
            listUser.AddRange(UserMock.listUsers.Select(u => (User)u.Clone()));
            listCourseProgram.AddRange(CourseProgramMock.listCourseProgram.Select(m => (CourseProgram)m.Clone()));
            listGroup.AddRange(GroupMock.groupMocks.Select(m => (Group)m.Clone()));
            listLesson.AddRange(LessonMock.lessonMocks.Select(m => (Lesson)m.Clone()));
            listCourse.AddRange(CourseMock.listCourse.Select(m => (Course)m.Clone()));

            for (int i = 0; i < listJournal.Count; i++)
            {
                listCity[i].Id = await dictionaryStorage.CityAddOrUpdate(listCity[i]);

                listUser[i].CityId = (int)listCity[i].Id;
                listUser[i].Id     = await userStorage.UserAddOrUpdate(listUser[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]);

                listJournal[i].LessonID = (int)listLesson[i].Id;
                listJournal[i].UserId   = (int)listUser[i].Id;
                listJournal[i].Id       = await lessonStorage.AddOrUpdateJournal(listJournal[i]);
            }
        }
Example #2
0
        public async Task <ActionResult <int> > AddOrUpdateJournal([FromBody] JournalFullInputModel inputModel)
        {
            Journal journal = JournalFullMapper.ToDataModel(inputModel);

            if (journal == null)
            {
                return(BadRequest("Model is empty"));
            }
            return(Ok(await lessonStorage.AddOrUpdateJournal(journal)));
        }