Example #1
0
        public async Task <ActionResult <int> > InsertNewCourseProgram([FromBody] CourseProgramInputModel newProgram)
        {
            if (newProgram == null)
            {
                return(BadRequest("Model is empty"));
            }
            var courseProgramId = await courseStorage.CourseProgramAddOrUpdate(CourseProgramMapper.ToCourseProgram(newProgram));

            if (courseProgramId.Equals(null))
            {
                return(BadRequest("Failed to add object"));
            }

            return(Ok(courseProgramId));
        }
Example #2
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 #3
0
        public async Task Setup()
        {
            listTeacherGroup.AddRange(TeacherGroupMock.listTeacherGroup);


            listCity          = DictionaryMocks.cityMock;
            listUser          = UserMock.listUsers;
            listCourseProgram = CourseProgramMock.listCourseProgram;
            listGroup         = GroupMock.groupMocks;
            listCourses       = CourseMock.listCourse;



            for (int i = 0; i < listTeacherGroup.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]);

                listCourses[i].Id = await courseStorage.CourseAddOrUpdate(listCourses[i]);

                listCourseProgram[i].CourseId = (int)listCourses[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]);

                listTeacherGroup[i].UserId  = (int)listCity[i].Id;
                listTeacherGroup[i].GroupId = (int)listGroup[i].Id;
                listTeacherGroup[i].Id      = await groupStorage.TeacherGroupInsert(listTeacherGroup[i]);
            }
        }
Example #4
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]);
            }
        }
Example #5
0
        public async Task CreateCourseProgram()
        {
            coursePrograms = new List <CourseProgram>(CourseProgramMock.listCourseProgram.Select(x => (CourseProgram)x.Clone()));
            var courseId = await storage.CourseAddOrUpdate((Course)listCourse[0].Clone());

            coursePrograms[1].CourseId = courseId;
            coursePrograms[0].CourseId = courseId;

            var courseProgramId = await storage.CourseProgramAddOrUpdate(coursePrograms[0]);

            coursePrograms[0].Id = courseProgramId;
            coursePrograms[1].Id = courseProgramId;
            var courseProgram = await storage.CourseProgramGetById(courseProgramId);

            //courseProgram.ProgramDetails = coursePrograms[1].ProgramDetails;
            Assert.IsTrue(DeepEqual(coursePrograms[0], courseProgram));
        }
Example #6
0
        public async Task Setup()
        {
            listCourseProgramSkill.AddRange(CourseProgramSkillMocks.listCourseProgramSkill.Select(x => (CourseProgramSkill)x.Clone()));
            listCourses.AddRange(CourseMock.listCourse.Select(x => (Course)x.Clone()));
            listcourseProgram.AddRange(CourseProgramMock.listCourseProgram.Select(x => (CourseProgram)x.Clone()));

            for (int i = 0; i < listCourses.Count; i++)
            {
                listCourses[i].Id = await courseStorage.CourseAddOrUpdate((Course)listCourses[i].Clone());

                listcourseProgram[i].CourseId = (int)listCourses[i].Id;
                listcourseProgram[i].Id       = await courseStorage.CourseProgramAddOrUpdate(listcourseProgram[i]);

                listCourseProgramSkill[i].CourseProgramId = (int)listcourseProgram[i].Id;
                listCourseProgramSkill[i].Id = await courseStorage.CourseProgramSkillAddOrUpdate(listCourseProgramSkill[i]);
            }
        }
Example #7
0
        private async Task Setup()
        {
            listNews      = new List <News>(NewsMock.listNews.Select(x => (News)x.Clone()));
            user1         = (User)UserMock.listUsers[0].Clone();
            user2         = (User)UserMock.listUsers[1].Clone();
            group         = (Group)GroupMock.groupMocks[0].Clone();
            course        = (Course)CourseMock.listCourse[0].Clone();
            courseProgram = (CourseProgram)CourseProgramMock.listCourseProgram[0].Clone();
            city          = (City)DictionaryMocks.cityMock[0].Clone();

            var createdCityId = await dictionaryStorage.CityAddOrUpdate(city);

            user1.CityId = (int)createdCityId;
            user2.CityId = (int)createdCityId;

            listNews[0].AuthorId = await userStorage.UserAddOrUpdate(user1);

            listNews[0].RecipientID = await userStorage.UserAddOrUpdate(user2);

            listNews[1].AuthorId = await userStorage.UserAddOrUpdate(user2);

            courseProgram.CourseId = await courseStorage.CourseAddOrUpdate(course);

            group.CourseProgramId = await courseStorage.CourseProgramAddOrUpdate(courseProgram);

            listNews[1].GroupID = await groupStorage.GroupAddOrUpdate(group);

            for (int i = 0; i < listNews.Count; i++)
            {
                News inputmodel = new News()
                {
                    AuthorId        = listNews[i].AuthorId,
                    Content         = listNews[i].Content,
                    GroupID         = listNews[i].GroupID,
                    Id              = listNews[i].Id,
                    PublicationDate = listNews[i].PublicationDate,
                    RecipientID     = listNews[i].RecipientID,
                    Title           = listNews[i].Title
                };
                int id = await newsStorage.NewsAddOrUpdate(inputmodel);

                listNews[i].Id = id;
                listNews[i].PublicationDate = (await newsStorage.NewsGetById(id)).PublicationDate;
            }
        }
Example #8
0
        public async void Setup()
        {
            listTimetable.AddRange(TimeTableMock.listTimetable);

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

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

                GroupMock.groupMocks[i].CourseProgramId = (int)CourseProgramMock.listCourseProgram[i].Id;
                GroupMock.groupMocks[i].Id = groupStorage.GroupAddOrUpdate(GroupMock.groupMocks[i]).Result;
                listTimetable[i].GroupId   = (int)GroupMock.groupMocks[i].Id;
                //    int? id = lessonStorage.AddOrUpdateTimeTable(listTimetable[i]);
                //      listTimetable[i].Id = id;
            }
        }
Example #9
0
        public async void Setup()
        {
            DictionaryMocks.cityMock[0].Id = dictionaryStorage.CityAddOrUpdate(DictionaryMocks.cityMock[0]).Result;
            UserMock.listUsers[0].CityId   = (int)DictionaryMocks.cityMock[0].Id;
            UserMock.listUsers[0].Id       = await userStorage.UserAddOrUpdate(UserMock.listUsers[0]);

            CourseMock.listCourse[0].Id = await courseStorage.CourseAddOrUpdate(CourseMock.listCourse[0]);

            CourseProgramMock.listCourseProgram[0].CourseId = (int)CourseMock.listCourse[0].Id;
            CourseProgramMock.listCourseProgram[0].Id       = await courseStorage.CourseProgramAddOrUpdate(CourseProgramMock.listCourseProgram[0]);

            listCourseProgramSkill = CourseProgramSkillMocks.listCourseProgramSkill;
            listCourseProgramSkill[0].CourseProgramId = (int)CourseProgramMock.listCourseProgram[0].Id;
            listCourseProgramSkill[0].Id = await courseStorage.CourseProgramSkillAddOrUpdate(listCourseProgramSkill[0]);

            UserSkillMock.listUserSkill[0].UserId  = (int)UserMock.listUsers[0].Id;
            UserSkillMock.listUserSkill[0].SkillId = (int)listCourseProgramSkill[0].Id;
            UserSkillMock.listUserSkill[0].Id      = await userStorage.UserSkillAdd(UserSkillMock.listUserSkill[0]);
        }
Example #10
0
        public async void Setup()
        {
            listStudentGroup.AddRange(StudentGroupMock.listStudentGroup);

            for (int i = 0; i < listStudentGroup.Count; i++)
            {
                DictionaryMocks.cityMock[i].Id = dictionaryStorage.CityAddOrUpdate(DictionaryMocks.cityMock[i]).Result;
                UserMock.listUsers[i].CityId   = (int)DictionaryMocks.cityMock[i].Id;
                UserMock.listUsers[i].Id       = await userStorage.UserAddOrUpdate(UserMock.listUsers[i]);

                CourseMock.listCourse[i].Id = await courseStorage.CourseAddOrUpdate(CourseMock.listCourse[i]);

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

                GroupMock.groupMocks[i].CourseProgramId = (int)CourseProgramMock.listCourseProgram[i].Id;
                GroupMock.groupMocks[i].Id = groupStorage.GroupAddOrUpdate(GroupMock.groupMocks[i]).Result;
                StudentGroupMock.listStudentGroup[i].UserId  = (int)UserMock.listUsers[i].Id;
                StudentGroupMock.listStudentGroup[i].GroupId = (int)GroupMock.groupMocks[i].Id;
                StudentGroupMock.listStudentGroup[i].Id      = groupStorage.StudentGroupInsert(StudentGroupMock.listStudentGroup[i]).Id;
            }
        }