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)); }
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()); }
[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("Учитель не может добавлять темы в уроки этих групп"); } }