示例#1
0
        public async Task <ActionResult <IEnumerable <GroupOutputModel> > > GetAllGroupByUser(int userId)
        {
            if (userId.Equals(null))
            {
                return(BadRequest("Group Id is empty"));
            }
            var result = GroupMapper.ToOutputModels(await groupStorage.GetTeacherGroupsById(userId));

            if (result.Equals(null))
            {
                return(BadRequest("Failed to add object"));
            }
            return(Ok(result));
        }
示例#2
0
        public async Task <ActionResult> EditUserAttestation([FromBody] UserAttestationWideInputModel model)
        {
            if (model == null || model.StudentId < 1)
            {
                return(BadRequest());
            }
            IEnumerable <Group> groups = await groupStorage.GetTeacherGroupsById(model.TeacherId);

            StudentGroup tempStudentGroup = await groupStorage.StudentGroupGetByUserId(model.StudentId);

            Group group = await groupStorage.GroupGetById(tempStudentGroup.GroupId);

            if (groups.Contains(group))
            {
                await userAttestationStorage.UserAttestationEdit(UserAttestationWideMapper.ToDataModels(model));
            }
            return(Ok());
        }
示例#3
0
        [HttpPost("themes")]  //  /api/lesson/themes
        public async Task AddTopicsToLesson([FromBody] LessonWithTopicsInputModel lessonWithTopicsInputModel)
        {
            IEnumerable <ThemeDetails> allThemes = await courseStorage.ThemeDetailsGetByGroupId(lessonWithTopicsInputModel.GroupId);

            IEnumerable <int>   themesToLearn = allThemes.Select(g => (int)g.Id).ToList();
            IEnumerable <Group> teacherGroups = await groupStorage.GetTeacherGroupsById(lessonWithTopicsInputModel.TeacherId);

            if (teacherGroups.Select(g => g.Id).Contains(lessonWithTopicsInputModel.GroupId))
            {
                foreach (var item in lessonWithTopicsInputModel.ThemeDetailsIds.Distinct())
                {
                    if (themesToLearn.Contains(item))
                    {
                        await lessonStorage.AddLessonTopic(new LessonTopic { LessonId = lessonWithTopicsInputModel.LessonId, ThemeDetailsId = item });
                    }
                }
            }
            else
            {
                Console.WriteLine("Учитель не может добавлять темы в уроки этих групп");
            }
        }