public async Task <ActionResult <int> > SetHometask([FromBody] LessonHometaskInputModel inputModel) { bool isUserInGroup = inputModel.GroupId == (await groupStorage.StudentGroupGetByUserId((int)inputModel.UserId)).GroupId; if (isUserInGroup) { return(await lessonStorage.AddOrUpdateLesson(LessonHometaskMapper.ToDataModel(inputModel))); } else { return(-1); } }
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]); } }
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]); } }