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); } }
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()); }
private async Task <bool> CreationIsAllowed(int teacherId, int studentId) { StudentGroup group = await groupStorage.StudentGroupGetByUserId(studentId); return(await groupStorage.GetBelongnessOfGroupToTheTeacher(Convert.ToInt32(group.GroupId), teacherId)); }